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

176
Vistas
Get an array of elements and navigate childrens with Puppeteer

I need to get an array of elements with the same class ID, which is class = "col-lg-3 col-md-4 col-xs-4 mb-30" in my case. To then get various data from each element of this array, such as an image. This is the site for example: https://altadefinizione.sale/?s=matrix I've tried with const feedHandle = await page.$$('.col-lg-3.col-md-4.col-xs-4.mb-30'); but the result is a handle that don't allow you to navigate to children. Ty for the help.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try to do all the DOM processing inside page.evaluate(), it is the simplest way:

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();

try {
  const [page] = await browser.pages();

  await page.goto('https://altadefinizione.sale/?s=matrix');

  const data = await page.evaluate(() => {
    const divs = document.querySelectorAll('.col-lg-3.col-md-4.col-xs-4.mb-30');
    const imgSources = Array.from(divs, div => div.querySelector('img').src);
    return imgSources;
  });
  console.log(data);
} catch (err) { console.error(err); } finally { await browser.close(); }
about 4 years ago · Juan Pablo Isaza Denunciar
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