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

125
Vistas
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 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