1

Is there a way to get all stored cookies for a certain browser?

I searched the web but only referrals to javascript or something like this Retrieving all Cookies in Python which works fine after some adjustments but only give me the cookies from a specific site.

But I want to read out all cookies let's say which are stored by Chrome or Safari.

How can I do this with python? Is there a global system variable I can request or read?

Andreas K.
  • 389
  • 4
  • 17
  • 1
    Example for Firefox: https://stackoverflow.com/questions/49502254/how-to-import-firefox-cookies-to-python-requests – Spirit Dec 12 '18 at 12:07
  • Thanks for the link. This was exactly what helped. I didn't image that it get stored in sqlite. Same seems true foe chrome. – Andreas K. Dec 12 '18 at 12:21

1 Answers1

5

I think you need this module https://github.com/borisbabic/browser_cookie3. With that you can simply get list of all cookies for Chrome by:

import browser_cookie3 cookies = list(browser_cookie3.chrome())

Now just parse the list as you need to.

JirkaV
  • 943
  • 1
  • 10
  • 16
  • Thanks. This gives me a great template to use. But it seems to be written for windows? – Andreas K. Dec 12 '18 at 14:55
  • You are welcome :) About the Windows - I tested it on my Ubuntu 18.04 and it works. I guess there is some polyfill for all systems in the code. – JirkaV Dec 13 '18 at 08:59