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.
Related Articles
Integrate Next-Auth authentication with Django backend, FastAPI API, and Next.js frontend for secure user authentication.
How to create a full stack app with Django, FastAPI and Next.js.
Start Creating Freedom today
Learn to build fast, scalable SaaS as I document my journey towards freedom. Follow along for real-world lessons and insights from my experiences.