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()));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.