Skip to content
This is a fork of browser_cookie
Branch: master
Clone or download
Latest commit cfc3944 Apr 30, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore initial fork Apr 26, 2015
LICENSE Initial commit Apr 26, 2015 initial fork Apr 26, 2015
README Support chrome >= 56 Apr 30, 2018 Add cookie file creation to Aug 6, 2018 Support profiles for firefox dev edition Apr 29, 2019 Bump version Apr 30, 2019

This is a python3 fork of Richard Penman's Browser Cookie

Browser Cookie

  • What does it do? Loads cookies used by your web browser into a cookiejar object.
  • Why is it useful? This means you can use python to download and get the same content you see in the web browser without needing to login.
  • Which browsers are supported? Currently Chrome and Firefox.
  • How are the cookies stored? In a sqlite database in your home directory.



    pip3 install browser-cookie3


Here is a dangerous hack to extract the title from a webpage:

>>> import re
>>> get_title = lambda html: re.findall('<title>(.*?)</title>', html, flags=re.DOTALL)[0].strip()

And here is the webpage title when downloaded normally:

>>> import urllib2
>>> url = ''
>>> public_html = urllib2.urlopen(url).read()
>>> get_title(public_html)
'Git and Mercurial code management for teams'

Now let's try with browser_cookie3 - make sure you are logged into Bitbucket in Firefox before trying this example:


>>> import browser_cookie3
>>> cj = browser_cookie3.firefox()
>>> opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
>>> login_html =
>>> get_title(login_html)
'richardpenman / home &mdash; Bitbucket'

You should see your own username here, meaning the module successfully loaded the cookies from Firefox.

Here is an alternative example with requests, this time loading the Chrome cookies. Again make sure you are logged into Bitbucket in Chrome before running this:


>>> import browser_cookie3
>>> import requests
>>> cj =
>>> r = requests.get(url, cookies=cj)
>>> get_title(r.content)
'richardpenman / home &mdash; Bitbucket'

Alternatively if you don't know/care which browser has the cookies you want then all available browser cookies can be loaded:


>>> import browser_cookie3
>>> import requests
>>> cj = browser_cookie3.load()
>>> r = requests.get(url, cookies=cj)
>>> get_title(r.content)
'richardpenman / home &mdash; Bitbucket'

Alternatively if you are only interested in cookies from a specific domain, you can specify a domain filter.


>>> import browser_cookie3
>>> import requests
>>> cj ='')
>>> r = requests.get(url, cookies=cj)
>>> get_title(r.content)
'richardpenman / home &mdash; Bitbucket'

Fresh cookie files

Creating and testing a fresh cookie file can help eliminate some possible user specific issues. It also allows you to upload a cookie file you are having issus with, since you should never upload your main cookie file!

Chrome and chromium

For linux and assumably mac:

Run google-chrome-stable --user-data-dir=browser_cookie3 #replace google-chrome-stable with your command to start chrome/chromium and when you close the browser you will have a new cookie file at browser_cookie3/Default/Cookies

If you want to share a cookie file then visit some site that will generate cookie (without logging in!), example will save cookies after you accept the GDPR notice.


So far the following platforms are supported:

  • Chrome: Linux, OSX, Windows
  • Firefox: Linux, OSX, Windows

Testing Dates

OS Chrome Firefox
Mac 1/6/16 1/6/16
Linux 1/6/16 1/6/16
Windows 1/6/16 n/a

However I only tested on a single version of each browser and so am not sure if the cookie sqlite format changes location or format in earlier/later versions. If you experience a problem please open an issue which includes details of the browser version and operating system. Also patches to support other browsers are very welcome, particularly for Chrome and Internet Explorer on Windows.


Special thanks to Nathan Henrie for his example of how to decode the Chrome cookies.

You can’t perform that action at this time.