首页 > 解决方案 > Puppeteer save file downloaded from background_page

问题描述

I am using Puppeteer to click a button on page, after that it auto opens a pop up and auto download file.

How to capture that file? I want to save it on server by headless mode.

标签: google-chromegoogle-chrome-extensiondownloadpuppeteerheadless

解决方案


您可以尝试以下方法

await page._client.send('Page.setDownloadBehavior', {behavior: 'allow', downloadPath: '/home/me/stuff'});

该文件将存储在该目录中,因此您可以稍后检查它。


推荐阅读