/export-cookie-for-puppeteer

Browser extension that outputs a cookie JSON file that can be imported by Puppeteer

Primary LanguageJavaScript

icon Export cookie JSON file for Puppeteer

Browser extension that outputs a cookie JSON file that can be imported by Puppeteer or cheerio-httpcli.

Install

Usage

By clicking on the extension icon, you can save the cookie information stored on the currently open page as a JSON file.

image1 image2

The saved JSON file can be used as follows.

Puppeteer

const puppeteer = require('puppeteer');
  .
  .
  .
const browser = await puppeteer.launch({ headless: true });
const page = await browser.newPage();
const cookies = JSON.parse(fs.readFileSync(<Exported cookie JSON file>, 'utf-8'));
for (const cookie of cookies) {
  await page.setCookie(cookie);
}
await page.goto(...);

cheerio-httpcli

const client = require('cheerio-httpcli');
  .
  .
  .
const cookies = JSON.parse(fs.readFileSync(<Exported cookie JSON file>, 'utf-8'));
client.importCookies(cookies);
client.fetch(...);

License

MIT license

© 2020 ktty1220