Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

124
Vistas
Request and Cheerio (data scraping packages for JavaScript) prints data but will not add to array

I am trying to store tracking data from the ISS using request and Cheerio for JS, I have got to the point that I can print the data but when trying to store the data in an array it returns undefined.

data.push(tr.text().split("|")); //will not put anything in the array data

console.log(tr.text().split("|")); //does exactly what i want it to

var data = [];

function sendReq(){

request('https://spotthestation.nasa.gov/sightings/view.cfm?country=Canada&region=Newfoundland&city=Saint_Johns#.YmhIZdPMK5c', 
    function (error, response, html) {

        if (!error && response.statusCode == 200) { 
            var $ = cheerio.load(html); 
            $('table').each(function(){
                
                var tr = $(this).next(); 

                data.push(tr.text().split("|")); //wont put into array data

                //console.log(tr.text().split("|")); //works perfectly fine
                
            }); 
        }

    });
}

sendReq();

console.log(data);
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda