Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

181
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!