How to download files using Puppeteer with headless: true

Asked

Viewed 280 times

0

I have a system that searches download websites, some zip files, the download is working perfect when I use the mode:

const browser = await puppeteer.launch({headless: False})
const page = await browser.newPage()

But when I put it as true, and it gets "Hidden" does nothing when you click download, I tested it on several systems and none download it.

I searched in stackoverflow in English, I found some people talking to set the following command, but it does not work.

await page._client.send('Page.setDownloadBehavior', {behavior: 'allow', downloadPath: 'c:\\XML'});

I haven’t found any other kind of answers on this subject yet, and from what I researched, this is a question asked in forums since 2017, I imagine that now there is a solution.

  • Opa Luan, there is some reason why you need to use the headless equal to true?

  • Yes, the idea is that the process be hidden.

  • There is data integration, and integration with other companies' Apis. The problem is with large companies that cannot do this partnership, and send us data by API. Therefore, we need to log into the web platforms and export the data daily, using the client’s own login. In such cases, we install a local application that goes to the system, extracts the notes and puts them in the cloud It is not interesting for the client to see the browser moving by itself, but the idea is just to make life easier for customers so that they do not need to extract this data

  • I get it, pupeteer is something I’m very interested in, I’ll study some way to do it.

  • Thank you very much, I do not know if you remember but who indicated the tool was you in another question, you already helped me a lot :)

  • Yes, I do, so I’m actually interested in helping out more kkkk

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.