Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

puppeteer - how to set download location

I was able to successfully download a file with puppeteer, but it was just saving it to my /Downloads folder. I've been looking around and can't find anything in the api or forums to set this location.

My downloads are basically just go going to the link:

await page.goto(url);
like image 398
A. L Avatar asked Oct 27 '17 01:10

A. L


People also ask

Can puppeteer download files?

Setting up a download path and reading from the disk _client API which gives us access to all the functions of the underlying developer console protocol. Basically, it extends Puppeteer's functionality. Then we can download the file by clicking on it.

Can puppeteer run in browser?

Puppeteer runs headless by default, but can be configured to run full (non-headless) Chrome or Chromium.

Is puppeteer an API?

Puppeteer is a Node library which provides a high-level API to control Chrome or Chromium over the DevTools Protocol.


1 Answers

This is how you can set the download path in latest puppeteer v0.13.

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

The behaviour is experimental, it might be removed, modified, or changed later.

Pst, you can try more tricks listed here, on your own risk :).

like image 136
Md. Abu Taher Avatar answered Sep 21 '22 02:09

Md. Abu Taher