Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

191
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda