Skip to main content

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

Project description

pycookiecheat

Build Status

Borrow cookies from your browser’s authenticated session for use in Python scripts.

Installation

NB: Use pip and python instead of pip3 and python3 if you’re still on Python 2.

Quickstart

  • pip3 install pycookiecheat

Development Setup

  1. git clone https://github.com/n8henrie/pycookiecheat.git

  2. cd pycookiecheat

  3. python3 -m venv venv

  4. venv/bin/pip install -e .[dev]

Usage

from pycookiecheat import chrome_cookies
import requests

url = 'http://example.com/fake.html'

# 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')

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

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

History

0.3.0

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 setup.py

  • Bugfix for python2 on linux

0.1.9

  • Bugfix for python2 on linux

0.1.8

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 (n8henrie.com)

  • 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.

Project details


Download files

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

Source Distribution

pycookiecheat-0.3.1.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pycookiecheat-0.3.1-py2.py3-none-any.whl (7.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pycookiecheat-0.3.1.tar.gz.

File metadata

  • Download URL: pycookiecheat-0.3.1.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pycookiecheat-0.3.1.tar.gz
Algorithm Hash digest
SHA256 4d004d69aef7681b6248d3cb80da114e72d719ec5cf7e5fa1da7a3e1c5ec7d7b
MD5 0d8c4b73f2c1f8561a58bb0b7ccbf0a5
BLAKE2b-256 100e4e1a6245876d431b160436fc5dc93d0d80f2d10f6d21938665f6d5da83c3

See more details on using hashes here.

File details

Details for the file pycookiecheat-0.3.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pycookiecheat-0.3.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ea778c30975f910ef6e0bf4632228663ad9a1f67040801d4595134a0c1086641
MD5 8d1a414475c718cf5a1930fb050dae0f
BLAKE2b-256 c2005285c95fd064799811add5ac62a8a184028eb1eb7fea7ccc93ae051a6221

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page