The problem is, that the buffer is cleared as soon as any kind of navigation request is happening. My question is: Is there some way (using puppeteer), to intercept the download stream without having to save the file to disk before? I noticed that some people use a solution based on reading files, in the other words, after download finishes, them read the stored file from the disk. I'm not sure if that's the correct approach. With such code above, I would intend to detect the event of the download dialog and then, in some way, be able to receive the binary content. I tried (unsuccessfully) to use the page.on("response") event to retrieve the raw response content, acording the following snippet: const bucket = Īwait page.on("response", async response => Looking for some examples in the web, I noticed that there is a lot of people with this problem. So far I wasn't able to find out some solution. I want to get the download content (buffer) and after soon, store the data at my S3 account. const puppeteer = require ( 'puppeteer' ) const fs = require ( 'fs' ) const path = require ( 'path' ) require ( 'dotenv' ). The code is for a very specific situation and therefore would need to be modified accordingly dependant on your requirements. The full code can be seen below, and the repo is available at. Requirements - For this you'll need a recent version of NodeJs (tested with version 14.14.0). This gave me a good excuse to try and automate the process as much as possible using puppeteer. I needed to download a video that was behind a login screen.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |