【发布时间】:2019-05-23 00:48:41
【问题描述】:
我正在抓取一个网页,我只需要下载该网页上符合特定条件的文件。如何在 puppeteer 中实现这一点?
我可以使用选择器定位元素并使用page.$$eval 获取我需要的属性,但我不知道如何点击该链接。
const sectionLinks = await page.$$eval('#mainsection a', aTags => aTags.map(a => a.innerText));
for (const sectionLink of sectionLinks) {
if (sectionLink.toUpperCase() == 'THEONEIWANT') {
console.log('download');
//this is where I want to click the link
}
}
【问题讨论】:
标签: javascript node.js puppeteer