Puppeteer to download file with Page.setDownloadBehavior
See original GitHub issueI am currently having issues downloading a file via URL. The download itself is working, but an incorrect extension of “.crdownload” is added to the end of the working extension.
Steps to reproduce
Environment:
- Puppeteer version: ^0.12.0
Steps:
const reportLink = await page.$('table.icwTable > tbody#myReportResults > tr:nth-child(1) > td:nth-child(2) > a');
await page._client.send('Page.setDownloadBehavior', {behavior: 'allow', downloadPath: './'});
await reportLink.click({ clickCount: 1, delay: 100 });
- Select the download URL
- Set download behavior with Chrome DevTools Protocol Viewer
- Click the link to download
Ideally the file would be downloaded and the extension would be “.xls”.
Currently the file is being downloaded, but with a file extension of “.xls.crdownload”. If I delete “.crdownload” manually the file downloads correctly - how do I stop the extra “.crdownload” extension from being added.
Issue Analytics
- State:
- Created 6 years ago
- Comments:34 (8 by maintainers)
Top Results From Across the Web
How to download a file with Puppeteer? - ScrapingBee
In this article, we will discuss how to efficiently download files with Puppeteer. Automating file downloads can sometimes be complicated.
Read more >Dealing with file downloads in puppeteer - browserless docs
Using our prior example we'll set this to generate a file for illustration purposes: await page._client.send('Page.setDownloadBehavior', { behavior: 'allow', ...
Read more >NodeJS Puppeteer setDownloadBehavior issue
So, it ignores downloadPath option and puts the file to default C:/Users/Me/Downloads folder. Also it does not wait for 5 seconds, it only...
Read more >How to download a file with Puppeteer? - ScrapFly
To download files with Puppteer we can either the browser's fetch feature - which will download the file into a javascript variable -...
Read more >Handling file download with Puppeteer - Help · Apify
Basically, it extends Puppeteer's functionality. Then we can download the file by clicking on it. await page.click('.export-button');. Let's wait ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I just set out to try if this bug occurred to me when trying to download
.csv
files. However, for me, it downloads just fine in headless and non-headless.Using
puppeteer ^0.13.0
, working just fine. ✅Hey guys, if it helps, what I noticed is that await page._client.send(‘Page.setDownloadBehavior’, {behavior: ‘allow’, downloadPath: ‘./’}); actually saved the file into the node_modules library where puppeteer/chromium was executing. So confirming what dallashuggins said: “…which downloads the file to a sibling folder on the same level as the file I am running (in the root directory).”
SO if you’re running puppeteer out of node_modules, then your path is relative to the puppeteer module directory: