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

131
Visualizações
puppeteer queryselectorall returns a null result when I use a variable that changes in a for loop

I want to do a queryselectorall scrape with 35 different selectors that differ only in the number in the middle, after each scrape I want to mark where it started and ended.

When I try to replace part of the selector with the number that changes in the loop it returns null with

---- start ----

----- end ----- The selector works if there is no variable but a number between 0-35

When I replace selectors in a chrome console like this it works. Could it be that I'm making a mistake?, how to make it work in puppeteer?

//The usual stuff of puppateer....



var array = [];
for (let i = 0; i <= 35; i++) {


  const theopeninfo2 = await page.evaluate(() => {
    return Array.from(document.querySelectorAll("#accordion_wide_"+i+" > div > div.main > div:nth-child(1) > div.dynamic_cmp_wrapper.size_x2_3 > div.ad_additional_info_items_wide.dynamic_cmp.accordion_wide_theme > div.items_container > div:not(.delete)")).map( x=> x.innerText).join("\n")
})

let start = "----start----\n";
let end = "\n----end----";
let result_start = start.concat(theopeninfo2);
let result_start_end = result_start.concat(end);
array.push(result_start_end)
}
array = array.join("\n")
console.log (array)

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