I am with this issue for more or less two days and I didn't find anything on the web that help me with this.
I am making some automatic searches with puppeteer in order to get some information from a consultation web pages. In one of them, I want to get the downloaded file generated from a jquery form that pass the parameters through a POST action, so, the page doesn't open a new tab or window, only makes the process in the same tab and sends a response with the file. I have to make this process with the option headless setted as true because I want to do this in a remote server.
I applied this solution https://github.com/puppeteer/puppeteer/issues/299#issuecomment-612667670. The issue with this answer is that he receive the response resourceType as 'xhr' and the response that the page sends to me is as 'document', so I don't have the option to transform to buffer the response, and that changes everything.
I receive the response with the following headers:
_headers: {
'content-length': '54347',
'content-type': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
server: 'Kestrel',
'content-disposition': "attachment; filename=Procesos_20200603_082202106.docx; filename*=UTF-8''Procesos_20200603_082202106.docx",
date: 'Wed, 03 Jun 2020 13:22:01 GMT',
'set-cookie': 'f5avrbbbbbbbbbbbbbbbb=EOCOPAJOFEPKABAHACOBBAHGPONPKJGJFHIOPCCAJDCKFKNMHCEHHEDBBPAPFPOMEBNGIGFNPEEDGICLOPIBJAIINGLAPOCGHCNBDIIIABAFMONJPKDNMLEJBKMGJKPO; HttpOnly; secure\n' +
'f5avr0144002454aaaaaaaaaaaaaaaa=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/;'
}
As you can see the 'content-disposition' attribute of the headers shows that the file is there, but my question is: ¿How can I get the file data in order to write it in my disk locally?
I appreciate all your help. In advance thanks.