Skip to main content
Help improve PyPI by participating in a 5-minute user interface survey!

Loads cookies from your browser into a cookiejar object so can download with urllib and other libraries the same content you see in the web browser.

Project Description

The browsercookie module loads cookies used by your web browser into a cookiejar object. This can be useful if you want to use python to download the same content you see in the web browser without needing to login.


pip install browsercookie

On Windows the builtin sqlite module will raise an error when loading the FireFox database. An updated version of sqlite can be installed with:

pip install pysqlite


Here is a 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 browsercookie - make sure you are logged into Bitbucket in Firefox before trying this example:

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

Differences with Python3:

>>> import urllib.request
>>> public_html = urllib.request.urlopen(url).read()
>>> opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))

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 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:

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


So far the following platforms are supported:

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

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 Internet Explorer on Windows.


Release history Release notifications

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
browsercookie-0.7.2.tar.gz (4.8 kB) Copy SHA256 hash SHA256 Source None May 20, 2017

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page