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

189
Vistas
How to convert table data to array by using selenium+Javascript

I want to get HTML table data to cover to array by using selenium and Javascript. I test below code and I can get console.log(lm) in the for loop, but it shows array each loop.

the wepage is https://www.scoresandodds.com/mlb and click Game Details-->Line Movement

How I can get array(lm) at the end of the code? why I can not get any data in my code ?

    console.log("Line Movement=================================\n");
driver.findElement(By.xpath('//*[@id="line-movements-tab--65040"]/span')).click(); //Line Movement
await driver.sleep(2500);

let rowC = '';
driver.findElements(By.xpath('//*[@id="line-movements--65040"]/div/table/tbody/tr')).then( function(rows){
        console.log("[" + rows.length + "]" + "\n\n");
        rowC = rows.length;
});

var lm=[];
for (i=0; i<rowC; i++) {
            for (s=1; s<5; s++) {
                var addCellText=function(elem, doneCallback){
                             elem.getText().then(function(textValue){
                                     driver.sleep(1000);
                                     lm.push(textValue);
                                     return doneCallback(null);
                             });
                 };
                 xpath='//*[@id="line-movements--65040"]/div/table/tbody/tr[' + i + ']/td[' + s + ']';
                 driver.findElements(By.xpath(xpath)).then(function(elem){
                       async.each(elem, addCellText, function(error){
                                     driver.sleep(1000);
                                    //console.log(lm);
                       });
                   });
           }
}
console.log("lm");
console.log(lm);

each team has a different code such as 65040, please look at each games code in the html. For example today(5/30) ARI-ATL of the code is 65051.

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