Node.js PDF不';不要用木偶演员下载
所以我试着下载一个pdf文件,在弹出窗口中打开,就像这样 在此处使用此代码获取弹出窗口并将其下载到“/”Node.js PDF不';不要用木偶演员下载,node.js,pdf,web-scraping,puppeteer,Node.js,Pdf,Web Scraping,Puppeteer,所以我试着下载一个pdf文件,在弹出窗口中打开,就像这样 在此处使用此代码获取弹出窗口并将其下载到“/” const popUp = await popUpPromise await popUp.waitFor(5000) // await popUp.waitForSelector('.content') const pdf = await popUp.$$eval('html', e => e) await consol
const popUp = await popUpPromise
await popUp.waitFor(5000)
// await popUp.waitForSelector('.content')
const pdf = await popUp.$$eval('html', e => e)
await console.log(pdf)
await popUp._client.send('Page.setDownloadBehavior', {behavior: 'allow', downloadPath: './'})
但它不仅没有像我预期的那样下载,而且弹出窗口中的html返回为空。要从弹出窗口下载pdf,您需要在弹出窗口加载后模拟按ctrl-s。它应该下载到您的downloadbehavior设置中指定的文件夹。尝试使用
wait page.type()
或wait page.press()