2
Network.getAllCookies

# Returns all browser cookies. Depending on the backend support, will return detailed cookie information in the cookies field.

RETURN OBJECT
cookies

array Cookie
Array of cookie objects.

enter image description here

Chrome Dev tool Guide

    (async() => {
      const browser = await puppeteer.launch({});
      const page = await browser.newPage();
      await page.goto('https://stack.com', {waitUntil : 'networkidle2' });
      // tried params like this as well
      // {waitUntil: 'load', timeout: 0}
      // {waitUntil: 'networkidle0', timeout: 0}
      // {waitUntil: 'domContentLoaded', timeout: 0}

      // Here we can get all of the cookies
      console.log(await page._client.send('Network.getAllCookies'));

    })();

Not returning all cookies - Any other function to get cookies set by third-party scripts in the site.?

mujuonly
  • 11,370
  • 5
  • 45
  • 75
  • I don't see any reason ( and I might be wrong ) why would you think it would be possible , as 3'rd party cookies can only be read by their own domain – Royi Namir Apr 11 '19 at 12:01
  • @RoyiNamir While submitting this URL in cookiemetrix, its getting 3 cookies - but puppeteer returns empty :( – mujuonly Apr 11 '19 at 12:05
  • I just tried your code and it worked. It showed me the third-party cookies for a domain. The domain in your code does not set any third-party cookies for me. – Thomas Dondorf Apr 11 '19 at 15:19
  • @ThomasDondorf The real website has coudflare cookie ( _cfduid ), because the site requesting to ipapi site. Puppeteer cant catch that :( – mujuonly Apr 12 '19 at 04:35

1 Answers1

2

If you're on macOs you can use the NPM package chrome-cookies-secure to pull them from your hard-disk. (https://www.npmjs.com/package/chrome-cookies-secure)

My related answer on a different post (https://stackoverflow.com/a/55630524/10732370).

Reece Daniels
  • 1,147
  • 12
  • 16