为什么 Puppeteer 没有下载到 Windows 中 "Page.setDownloadBehavior" 指定的文件夹中?
Why Puppeteer is not downloading into folder specified with "Page.setDownloadBehavior" in Windows?
我使用下面的代码让Puppeteer点击触发事件的按钮来实现文件的下载
await page._client.send(
'Page.setDownloadBehavior',
{
behavior: 'allow',
downloadPath: './temporal/files/',
},
);
它在 Mac OS 机器上工作得很好,但它在 Windows 一台
机器上什么都不做
包裹这个块的try/catch什么也抓不到,当我使用headless: false
设置时,它被证明是"download the file",但是根本没有文件硬盘
如果Windows API需要绝对路径,可以用__dirname
和相对路径组合。
我使用下面的代码让Puppeteer点击触发事件的按钮来实现文件的下载
await page._client.send(
'Page.setDownloadBehavior',
{
behavior: 'allow',
downloadPath: './temporal/files/',
},
);
它在 Mac OS 机器上工作得很好,但它在 Windows 一台
机器上什么都不做包裹这个块的try/catch什么也抓不到,当我使用headless: false
设置时,它被证明是"download the file",但是根本没有文件硬盘
如果Windows API需要绝对路径,可以用__dirname
和相对路径组合。