I need to take with Puppeteer all the data that a website saves: cookies and localStorage (for example after Login). I have read all Puppeteer documentation but I can not find anything about localStorage.
I can get cookies but I don't know to get localStorage. For example:
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch()
const page = await browser.newPage()
await page.goto('https://www.twitter.com/')
//
// code for login
//
const returnedCookie = await page.cookies();
console.log(returnedCookie)
// const localStorage = ??
// console.log(localStorage)
await browser.close()
})()
easier way that worked for me
const localStorage = await page.evaluate(() => Object.assign({}, window.localStorage));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With