Got this function from another developer and i'm trying to debug it. It's a web scraper based on puppeteer. But from some reason i can't console.log inside.
Can someone please point me to what am i'm missing here?
const getArticles = async (page) => {
  return await page.evaluate(() => {
  console.log('in page.evaluate')
//not printing anything in the console
    const products = document.querySelectorAll(".thumb-link")
    const formated = Array.from(products).map(x => x.href)
    console.log(22, formated)
    return Promise.resolve(formated.filter(x => x))
  });
}
let newArticles = await getArticles(page)
Add the following to see the browser's console log:
const page = await browser.newPage();
page.on('console', msg => console.log(msg.text()));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With