Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Borrow cookies from your browser's authenticated session foruse in Python scripts.

Project Description
# pycookiecheat


Borrow cookies from your browser's authenticated session for use in Python

- Free software: MIT
- Documentation:

## Installation

**NB:** Use `pip` and `python` instead of `pip3` and `python3` if you're still
on Python 2 and using pycookiecheat < v0.4.0. pycookiecheat >= v0.4.0 requires
Python 3.5+, and may soon go to 3.6+.

- `pip3 install pycookiecheat`

### Installation notes regarding alternative keyrings on Linux

See [#12]( Chrome is now
using a few different keyrings to store your `Chrome Safe Storage` password,
instead of a hard-coded password. Pycookiecheat doesn't work with most of these
so far, and to be honest my enthusiasm for adding support for ones I don't use
is limited. However, users have contributed code that seems to work with some
of the recent Ubuntu desktops. To get it working, you may have to `sudo apt-get
install libsecret-1-dev python-gi python3-gi`, and if you're installing into a
virtualenv (highly recommended), you need to use the `--system-site-packages`
flag to get access to the necessary libraries.

Alternatively, some users have suggested running Chrome with the
`--password-store=basic` or `--use-mock-keychain` flags.

### Development Setup

1. `git clone`
1. `cd pycookiecheat`
1. `python3 -m venv venv`
1. `venv/bin/pip install -e .[dev]`

## Usage

from pycookiecheat import chrome_cookies
import requests

url = ''

# Uses Chrome's default cookies filepath by default
cookies = chrome_cookies(url)
r = requests.get(url, cookies=cookies)

Use the `cookie_file` keyword-argument to specify a different filepath for the
cookies-file: `chrome_cookies(url, cookie_file='/abspath/to/cookies')`

Keep in mind that pycookiecheat defaults to looking for cookies for
Chromium, not Google Chrome, so if you're using the latter, you'll need to
manually specify something like
`"/home/username/.config/google-chrome/Default/Cookies"` as your `cookie_file`.

## Features

- Returns decrypted cookies from Google Chrome on OSX or Linux.

## FAQ / Troubleshooting

### How about Windows?

I don't use Windows or have a PC, so I won't be adding support myself. Feel
free to make a PR :)

### I get an installation error with the `cryptography` module on OS X
(pycookiecheat <v0.4.0)

If you're getting [this
and using Homebrew, then you need to follow the instructions for [Building
cryptography on OS
and `export LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix
openssl)/include"` and try again.

### I get an installation error with the `cryptography` module on Linux (pycookiecheat <v0.4.0)

Please check the official cryptography docs. On some systems (e.g. Ubuntu), you
may need to do something like `sudo apt-get install build-essential libssl-dev
libffi-dev python-dev` prior to installing with `pip`.

### How do I install the dev branch with pip?

- `pip install git+`

# [Changelog](

## v0.4.3 :: 20170627

- Consistently use Chrome as default across platforms, allow user to specify
Chromium as desired (thanks @jtbraun)

## v0.4.0 :: 20170504

- Remove compatibility for Python <3.5
- Add type hints
- Refactor for smaller functions
- Expand docstrings
- Revert from `cryptography` back to `PyCrypto` and `hashlib` for easier

## v0.3.4 :: 20170414

- Add support for new Ubuntu keyring / libsecret
- See <> for details
- Many thanks to @stat1c1c3au and @trideceth12 for contributions

## 0.3.0

- Use [`cryptography`]( instead of
`pycrypto` (thanks to [Taik](!)
- Seems to be [significantly
- Works with PyPy >= 2.6.0 (no support for PyPy3 yet)

## 0.2.0

- Fix domain and subdomain matching
- Make SQL query more secure by avoiding string formatting
- Many thanks to [Brandon Rhodes]( for 24c4234 !

## 0.1.10

- Read version to separate file so it can be imported in
- Bugfix for python2 on linux

## 0.1.9

- Bugfix for python2 on linux

## 0.1.8

- Python2 support (thanks [dani14-96](

## 0.1.7

- Configurable cookies file (thanks [ankostis](

## 0.1.6

- OSError instead of Exception for wrong OS.
- Moved testing requirements to tox and travis-ci files.

## 0.1.5

- Updated to work better with PyPI's lack of markdown support
- Working on tox and travis-ci integration
- Added a few basic tests that should pass if one has Chrome installed and has visited my site (
- Added sys.exit(0) if cookie_file not found so tests pass on travis-ci.

## 0.1.0 (2015-02-25)

- First release on PyPI.

## Prior changelog from Gist

- 20150221 v2.0.1: Now should find cookies for base domain and all subs.
- 20140518 v2.0: Now works with Chrome's new encrypted cookies.

Release History

Release History

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
pycookiecheat-0.4.3-py3-none-any.whl (10.3 kB) Copy SHA256 Checksum SHA256 py3 Wheel Jul 4, 2017
pycookiecheat-0.4.3.tar.gz (9.5 kB) Copy SHA256 Checksum SHA256 Source Jul 4, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting