thomasdondorf / puppeteer-cluster

Puppeteer Pool, run a cluster of instances in parallel
MIT License
3.2k stars 307 forks source link

Single setup before starting concurrent cluster? #507

Open DawidOskwarek opened 1 year ago

DawidOskwarek commented 1 year ago

Hey, sorry if this was answered before.

Is there a way to perform a single action/function before starting a concurrent cluster? I want to be able to sign in to a website once, and then every concurrent page that I start in a cluster will not have to log in again. How would I go about it? Any examples out there?

stoddabr commented 1 year ago

Depending on how the authentication is setup on the website (eg, if they support cookie sessions) if you run with the CONCURRENCY_PAGE setting then all other pages may be authorized after the first sign in

DanielXavierJob commented 1 year ago

As our dear friend replied above, using the concurrency: Cluster.CONCURRENCY_PAGE setting in the launch configuration, you can pass settings, cookies, localStorage from one browser to another, this way if the method of using the login whether by cookies, session, etc., this state will be passed on.

If not, you can create a Login class where it performs the steps to login, usually sites with login show when you are logged in, prefer to check if the user is logged in, if not, run this login steps function, then continue. Hope this helps!