Im really new to node.js and puppeteer.
Im trying to get all the links of the products when I search for them and save them but it only saves the first one and not the others. I dont know if my selectors are wrong or if the code is wrong.
const scraperObject = {
url: 'https://diaonline.supermercadosdia.com.ar/busca/?ft=pepsi',
async scraper(browser){
let page = await browser.newPage();
console.log(`Navigating to ${this.url}...`);
await page.goto(this.url);
// Wait for the required DOM to be rendered
await page.waitForSelector('.wrapper > .main');
// Get the link to all the required products
let urls = await page.$$eval('section > div.coleccion-prods > div > div.vitrine.resultItemsWrapper', links => {
links = links.filter(link => link.querySelector('.marca').textContent !== "PEPSI")
//Extract the links from the data
links = links.map(el => el.querySelector('h3 > a').href)
return links;
});
console.log(urls);
}
}
module.exports = scraperObject;
node.js vrs. 18.1.0
puppeteer vrs. 14.1.2