Skip to main content

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

Installation

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

PyPI

  • pip3 install pycookiecheat

GitHub

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

  2. cd pycookiecheat

  3. python3 setup.py install

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

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

History

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.1.10.tar.gz (14.3 kB view hashes)

Uploaded Source

Built Distribution

pycookiecheat-0.1.10-py2.py3-none-any.whl (6.6 kB view hashes)

Uploaded Python 2 Python 3

Supported by

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