How to download file with puppeteer using headless: true?

前端 未结 7 1691
攒了一身酷
攒了一身酷 2020-12-08 05:05

I\'ve been running the following code in order to download a csv file from the website http://niftyindices.com/resources/holiday-calendar:

7条回答
  •  轮回少年
    2020-12-08 05:49

    I have another solution to this problem, since none of the answers here worked for me.

    I needed to log into a website, and download some .csv reports. Headed was fine, headless failed no matter what I tried. Looking at the Network errors, the download is aborted, but I couldn't (quickly) determine why.

    So, I intercepted the requests and used node-fetch to make the request outside of puppeteer. This required copying the fetch options, body, headers and adding in the access cookie.

    Good luck.

提交回复
热议问题