So I am a little bit stuck here. I am doing some scraping with Puppeteer, but at some point I have to download a file. The problem is that the file is "generated" after a click on a button. I know how to do that on Puppeteer, also to catcha requests and responses from the page, however, none of them is of use.
So I have a button on a previous page, this is the button after inspecting it.
<button
id="ReporteOpinionForm:botonConsultar"
name="ReporteOpinionForm:botonConsultar"
class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only ui-button"
type="submit">
<span class="ui-button-text ui-c">
Consultar
</span>
</button>
By inspecting the whole page I can see that it uses Primefaces and JSF So once I click it a XHTMLRequest is sent to an XHML endpoint The response (on the right) is nothing more than an ID or some sort, also the method is POST and the body is FormData which has some unimportant stuff I think After a few seconds, a new page is loaded with the PDF embedded
But after inspecting the page, it only has an empty body
But if I go to the sources tab on the devtools I can see this
The content is a base64 encoded string, which if decoded to a PDF file, results in the file that can be seen on the viewer, so, the primary objective here is to download the file, I have tried several things.
• Catch the request and the response and copy the response, but the response of the XHMLHttpRequest is different and not the base64 string • Move the mouse to the PDF bar that appears on the top of the page and click on the download button, but that doesnt work either • Try to print the page into a PDF, however, the scripts breaks on headless mode when the button to generate the PDF is clicked.
I am lost and I don't know what to do or what I am missing or not seeing Any help would be appreciated, thanks