• Stars
    star
    690
  • Rank 65,522 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created over 9 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

pycookiecheat

master branch 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 and using pycookiecheat < v0.4.0. pycookiecheat >= v0.4.0 requires Python 3.5+, and may soon go to 3.6+.

  • python3 -m pip 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 https://github.com/n8henrie/pycookiecheat.git
  2. cd pycookiecheat
  3. python3 -m venv .venv
  4. ./.venv/bin/python -m 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')

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, Brave, or Slack, on OSX or Linux.
  • Optionally outputs cookies to file (thanks to Muntashir Al-Islam!)

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

I get an installation error with the cryptography module on Linux

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 can I use pycookiecheat on KDE-based Linux distros?

On KDE, Chrome defaults to using KDE's own keyring, KWallet. For pycookiecheat to support KWallet the dbus-python package must be installed.

How do I install the dev branch with pip?

  • python -m pip install git+https://github.com/n8henrie/pycookiecheat@dev

Buy Me a Coffee

☕️

More Repositories

1

fauxmo

Emulated Belkin WeMo devices that work with the Amazon Echo
Python
299
star
2

jupyter-black

A simple extension for Jupyter Notebook and Jupyter Lab to beautify Python code automatically using Black. Fork of dnanhkhoa/nb_black.
Python
54
star
3

icsConverter

Python app to convert .csv schedule to .ics file.
Python
40
star
4

nixos-btrfs-pi

Raspberry Pi SD card image for NixOS on BTRFS root
Nix
39
star
5

alexa-wolfram-alpha

Use your Amazon Echo (Alexa) to query Wolfram Alpha.
Python
24
star
6

rf_pi

Scripts and utilities for controlling 433 MHz RF outlets from a Raspberry Pi -- without requiring sudo / root
C++
13
star
7

fauxmo-plugins

Plugins for Fauxmo (emulated Wemo devices for the Amazon Echo)
Python
13
star
8

icw

Flask-based conversion of csv schedules into icalendar files.
Python
13
star
9

fastcli

Python3 speed test via Fast.com
Python
10
star
10

n8pythonista

This repo is no longer actively maintained. I found that Gists are better for this kind of thing. If you're looking for an updated version of something you find here, search my Gists or give me a shout.
Python
10
star
11

ofpy

Command line to OmniFocus script, via email or Dropbox and Hazel
Python
9
star
12

nixos-rescue

NixOS-based USB rescue image
Nix
8
star
13

nv

arm64 fork of scrod/nv
Objective-C
7
star
14

eyeflask

Simple Flask-based Python3 EyeFi server
Python
7
star
15

qs_messages

Send iMessages through Quicksilver with Python and AppleScript
AppleScript
6
star
16

icsConverterWebapp

Google App Engine hosted Python webapp to convert a properly formatted .csv file to functioning .ics file.
Python
5
star
17

hc-runner

Run stuff and report results to healthchecks
Rust
3
star
18

fixbashhistory

Remove duplicates in bash history file
Go
3
star
19

advent2018-rust

Advent of Code 2018, in rust
Rust
3
star
20

simplenet

A simple neural network in Python
Python
3
star
21

python_firefox_ext

Firefox extension in Python
Python
3
star
22

esp32c3-rust-mqtt

ESP32 + MQTT in Rust, built with nix
Rust
2
star
23

n8henrie

My GitHub profile
2
star
24

cookiecutter_gae_flask

Cookiecutter for Flask apps destined for Google Apps Engine
Python
2
star
25

n8henrie.github.io

Personal website for @n8henrie
HTML
2
star
26

cookiecutter-lambda

A cookiecutter or AWS Lambda functions
Python
2
star
27

rust_on_ios

SwiftUI frontend using a Rust shared library on the backend
Swift
1
star
28

nix-cadquery

nix-cadquery
Jupyter Notebook
1
star
29

rust-stm32

https://n8henrie.com/2019/04/blinking-an-stm32-with-rust-from-macos/
Rust
1
star
30

hello-wasm

https://developer.mozilla.org/en-US/docs/WebAssembly/Rust_to_wasm
JavaScript
1
star
31

rust-cli-template

Basic template for CLI apps in Rust
Rust
1
star
32

format-shell-command

Rust
1
star
33

urlmon

Python script to monitor URL for changes
Python
1
star
34

flake-templates

My personal flake templates
Nix
1
star
35

superdrive-enabler-git

Shell
1
star
36

speed

Thin wrapper around speedtest-cli to average a few results
Python
1
star
37

duckdns

Python script and systemd service and timer files to use dynamic dns from duckdns.org on your Raspberry Pi.
Makefile
1
star
38

aoc22-rust

My Advent of Code solutions for 2022, in Rust
Rust
1
star
39

brokencppmap

Toy Rust bindgen to C++ library via C wrapper example
Rust
1
star
40

taskwarrior-rs

Rust bindings for taskwarrior
Rust
1
star