Reputation: 117
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)
Upvotes: 3
Views: 3446
Reputation: 3013
Add the following to see the browser's console log:
const page = await browser.newPage();
page.on('console', msg => console.log(msg.text()));
Upvotes: 4