How to fetch authenticated CSV’s with Google Chrome (Headless) in NodeJS
How to fetch authenticated CSV’s with Google Chrome (Headless) in NodeJS.
Recently I had a use case where we need to log in to a third-party site and fetch protected CSV files. While PhantomJS (via CasperJS) can often accomplish this take, we have had issues with its stability often crashing, especially in Docker.
But that’s okay because Google Chrome (headless) is up to the task and has quite an awesome, simple API to use.
Here is a NodeJS sample using puppeteer to interact with Google Chrome (Headless). First, we need to install the puppeteer module.
Once the module has been installed create a Javascript file with the following contents.
Now we just need to run our sample and watch the output.
Damian Hodgkiss
Senior Staff Engineer at Sumo Group, leading development of AppSumo marketplace. Technical solopreneur with 25+ years of experience building SaaS products.