我正在尝试抓取一个网站上的多个 pdf 文件。但下载第一个后,chrome 要求我允许该网站下载多个文件。

我们可以在启动浏览器时允许这样做吗?一旦我手动允许并下载所有文件,这个代码就可以工作。
for(selector of selectors){
await this.currentPage._client.send('Page.setDownloadBehavior', { behavior: 'allow', downloadPath: downloadFilePath });
await this.currentPage.waitFor(1000);
await this.currentPage.evaluate(el => el.click(), selector);
await this.currentPage.waitFor(1000 * 20);
}
Run Code Online (Sandbox Code Playgroud)