DEV Community

Discussion on: Web Scraping — Scrape data from your instagram page with Nodejs, Playwright and Firebase.

Collapse
 
andyajhis profile image
andyajhis

Do u know, how to save login session after browser close and want to scraping again and again ?

Collapse
 
dnature profile image
Divine Hycenth

I haven't tried that and maybe it's possible but i'm sure it's not going to work if you randomly spin up browsers using Playwright.
Let me know if you are able to do that :)

Collapse
 
spidydev profile image
Cicada1033➿

go to your project directory
using the terminal,run the command below,
npx playwright open --save-storage websitename.json

a browser will open,now navigate to the website and sign-in/solve captcha,
then close browser. You will notice that a file "websitename.json" has been created.

now in playwright,set you browser context using this code below

const context = await browser.newContext({
storageState: "websitename.json"
});

you are now automatically logged in. :)