pycookiecheat


Namepycookiecheat JSON
Version 0.6.0 PyPI version JSON
download
home_page
SummaryBorrow cookies from your browser's authenticated session for use in Python scripts.
upload_time2023-09-22 21:28:09
maintainer
docs_urlNone
author
requires_python
licenseMIT
keywords pycookiecheat chrome chromium cookies cookies firefox
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pycookiecheat

[![master branch build
status](https://github.com/n8henrie/pycookiecheat/actions/workflows/python-package.yml/badge.svg?branch=master)](https://github.com/n8henrie/pycookiecheat/actions/workflows/python-package.yml)

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

-   Free software: MIT
-   Documentation: http://n8h.me/HufI1w

## 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](https://github.com/n8henrie/pycookiecheat/issues/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`
1. `cd pycookiecheat`
1. `python3 -m venv .venv`
1. `./.venv/bin/python -m pip install -e .[dev]`

## Usage

```python
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 Google
Chrome, not Chromium, so if you're using the latter, you'll need to manually
specify something like `"/home/username/.config/chromium/Default/Cookies"` (for
Linux) 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](https://github.com/n8henrie/pycookiecheat/pull/11#issuecomment-221918807)
and using Homebrew, then you need to follow the instructions for [Building
cryptography on OS
X](https://cryptography.io/en/latest/installation/?highlight=cflags#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`](https://pypi.org/project/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

[☕️](https://n8henrie.com/donate)

# [Changelog](https://keepachangelog.com)

## v0.6.0 :: 20230324

- Add firefox support , thanks to @grandchild
    - Also would like to welcome @grandchild as a new member of the
      pycookiecheat team!

## v0.5.0 :: 20230324

- Add support for Brave thanks to @chrisgavin!
- Add support for Slack thanks to @hraftery!
- Migrate config to pyproject.toml alone
- Minor cleanup to codebase and tests

## v0.4.7 :: 20210826

- No noteworthy API changes, hence the bugfix version bump, but some major
  infrastructure and testing updates:
    - Now uses GitHub Actions instead of Travis
    - Now uses Playwright for testing, to actually open a Chromium instance and
    use a real `Cookies` database
    - PEP517
    - black
- Now requires python >= 3.7
    - This is largely due to requiremets of Playwright:
      https://pypi.org/project/playwright/, which is only a *test* dependency
    - Because I can't *test* with <=3.6, I'm not listing it as compatible,
      though it *probably* will still work
- Migrate to pyproject.toml

## v0.4.6 :: 2019111

- Try to open Chrome database in read-only mode to avoid db locked errors (#29)

## v0.4.5 :: 20191007

- db6ac6d Go back to using cryptography due to
  https://www.cvedetails.com/cve/CVE-2013-7459/
- c70ad51 Allow users to override password (thanks @alairock)

## v0.4.4 :: 20180706

- Optionally outputs cookies to a file compatible with cURL (thanks to
  Muntashir Al-Islam!)

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

## v0.3.4 :: 20170414

- Add support for new Ubuntu keyring / libsecret
  - See <https://github.com/n8henrie/pycookiecheat/issues/12> for details
  - Many thanks to @stat1c1c3au and @trideceth12 for contributions

## 0.3.0

- Use [`cryptography`](https://cryptography.io/en/latest/) instead of
  `pycrypto` (thanks to [Taik](https://github.com/Taik)!)
  - Seems to be [significantly
    faster](https://github.com/n8henrie/pycookiecheat/pull/11#issuecomment-221950400)
  - 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](https://github.com/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

- Python2 support (thanks [dani14-96](https://github.com/dani14-96))

## 0.1.7

- Configurable cookies file (thanks [ankostis](https://github.com/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.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "pycookiecheat",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "pycookiecheat,chrome,chromium cookies,cookies,firefox",
    "author": "",
    "author_email": "Nathan Henrie <nate@n8henrie.com>",
    "download_url": "https://files.pythonhosted.org/packages/b7/f7/333ba3db009d757f78959436c9d5b9d72ef3781f64ac1e650022ea7c57d6/pycookiecheat-0.6.0.tar.gz",
    "platform": null,
    "description": "# pycookiecheat\n\n[![master branch build\nstatus](https://github.com/n8henrie/pycookiecheat/actions/workflows/python-package.yml/badge.svg?branch=master)](https://github.com/n8henrie/pycookiecheat/actions/workflows/python-package.yml)\n\nBorrow cookies from your browser's authenticated session for use in Python\nscripts.\n\n-   Free software: MIT\n-   Documentation: http://n8h.me/HufI1w\n\n## Installation\n\n**NB:** Use `pip` and `python` instead of `pip3` and `python3` if you're still\non Python 2 and using pycookiecheat < v0.4.0. pycookiecheat >= v0.4.0 requires\nPython 3.5+, and may soon go to 3.6+.\n\n- `python3 -m pip install pycookiecheat`\n\n### Installation notes regarding alternative keyrings on Linux\n\nSee [#12](https://github.com/n8henrie/pycookiecheat/issues/12). Chrome is now\nusing a few different keyrings to store your `Chrome Safe Storage` password,\ninstead of a hard-coded password. Pycookiecheat doesn't work with most of these\nso far, and to be honest my enthusiasm for adding support for ones I don't use\nis limited. However, users have contributed code that seems to work with some\nof the recent Ubuntu desktops. To get it working, you may have to `sudo apt-get\ninstall libsecret-1-dev python-gi python3-gi`, and if you're installing into a\nvirtualenv (highly recommended), you need to use the `--system-site-packages`\nflag to get access to the necessary libraries.\n\nAlternatively, some users have suggested running Chrome with the\n`--password-store=basic` or `--use-mock-keychain` flags.\n\n### Development Setup\n\n1. `git clone https://github.com/n8henrie/pycookiecheat.git`\n1. `cd pycookiecheat`\n1. `python3 -m venv .venv`\n1. `./.venv/bin/python -m pip install -e .[dev]`\n\n## Usage\n\n```python\nfrom pycookiecheat import chrome_cookies\nimport requests\n\nurl = 'http://example.com/fake.html'\n\n# Uses Chrome's default cookies filepath by default\ncookies = chrome_cookies(url)\nr = requests.get(url, cookies=cookies)\n```\n\nUse the `cookie_file` keyword-argument to specify a different filepath for the\ncookies-file: `chrome_cookies(url, cookie_file='/abspath/to/cookies')`\n\nKeep in mind that pycookiecheat defaults to looking for cookies for Google\nChrome, not Chromium, so if you're using the latter, you'll need to manually\nspecify something like `\"/home/username/.config/chromium/Default/Cookies\"` (for\nLinux) as your `cookie_file`.\n\n## Features\n\n- Returns decrypted cookies from Google Chrome, Brave, or Slack, on OSX or\n  Linux.\n- Optionally outputs cookies to file (thanks to Muntashir Al-Islam!)\n\n## FAQ / Troubleshooting\n\n### How about Windows?\n\nI don't use Windows or have a PC, so I won't be adding support myself. Feel\nfree to make a PR :)\n\n### I get an installation error with the `cryptography` module on OS X\n(pycookiecheat <v0.4.0)\n\nIf you're getting [this\nerror](https://github.com/n8henrie/pycookiecheat/pull/11#issuecomment-221918807)\nand using Homebrew, then you need to follow the instructions for [Building\ncryptography on OS\nX](https://cryptography.io/en/latest/installation/?highlight=cflags#building-cryptography-on-os-x)\nand `export LDFLAGS=\"-L$(brew --prefix openssl)/lib\" CFLAGS=\"-I$(brew --prefix\nopenssl)/include\"` and try again.\n\n### I get an installation error with the `cryptography` module on Linux\n\nPlease check the official cryptography docs. On some systems (e.g. Ubuntu), you\nmay need to do something like `sudo apt-get install build-essential libssl-dev\nlibffi-dev python-dev` prior to installing with `pip`.\n\n### How can I use pycookiecheat on KDE-based Linux distros?\n\nOn KDE, Chrome defaults to using KDE's own keyring, KWallet. For pycookiecheat to support KWallet the [`dbus-python`](https://pypi.org/project/dbus-python/) package must be installed.\n\n### How do I install the dev branch with pip?\n\n- `python -m pip install git+https://github.com/n8henrie/pycookiecheat@dev`\n\n## Buy Me a Coffee\n\n[\u2615\ufe0f](https://n8henrie.com/donate)\n\n# [Changelog](https://keepachangelog.com)\n\n## v0.6.0 :: 20230324\n\n- Add firefox support , thanks to @grandchild\n    - Also would like to welcome @grandchild as a new member of the\n      pycookiecheat team!\n\n## v0.5.0 :: 20230324\n\n- Add support for Brave thanks to @chrisgavin!\n- Add support for Slack thanks to @hraftery!\n- Migrate config to pyproject.toml alone\n- Minor cleanup to codebase and tests\n\n## v0.4.7 :: 20210826\n\n- No noteworthy API changes, hence the bugfix version bump, but some major\n  infrastructure and testing updates:\n    - Now uses GitHub Actions instead of Travis\n    - Now uses Playwright for testing, to actually open a Chromium instance and\n    use a real `Cookies` database\n    - PEP517\n    - black\n- Now requires python >= 3.7\n    - This is largely due to requiremets of Playwright:\n      https://pypi.org/project/playwright/, which is only a *test* dependency\n    - Because I can't *test* with <=3.6, I'm not listing it as compatible,\n      though it *probably* will still work\n- Migrate to pyproject.toml\n\n## v0.4.6 :: 2019111\n\n- Try to open Chrome database in read-only mode to avoid db locked errors (#29)\n\n## v0.4.5 :: 20191007\n\n- db6ac6d Go back to using cryptography due to\n  https://www.cvedetails.com/cve/CVE-2013-7459/\n- c70ad51 Allow users to override password (thanks @alairock)\n\n## v0.4.4 :: 20180706\n\n- Optionally outputs cookies to a file compatible with cURL (thanks to\n  Muntashir Al-Islam!)\n\n## v0.4.3 :: 20170627\n\n- Consistently use Chrome as default across platforms, allow user to specify\n  Chromium as desired (thanks @jtbraun)\n\n## v0.4.0 :: 20170504\n\n- Remove compatibility for Python <3.5\n- Add type hints\n- Refactor for smaller functions\n- Expand docstrings\n- Revert from `cryptography` back to `PyCrypto` and `hashlib` for easier\n  installation.\n\n## v0.3.4 :: 20170414\n\n- Add support for new Ubuntu keyring / libsecret\n  - See <https://github.com/n8henrie/pycookiecheat/issues/12> for details\n  - Many thanks to @stat1c1c3au and @trideceth12 for contributions\n\n## 0.3.0\n\n- Use [`cryptography`](https://cryptography.io/en/latest/) instead of\n  `pycrypto` (thanks to [Taik](https://github.com/Taik)!)\n  - Seems to be [significantly\n    faster](https://github.com/n8henrie/pycookiecheat/pull/11#issuecomment-221950400)\n  - Works with PyPy >= 2.6.0 (no support for PyPy3 yet)\n\n## 0.2.0\n\n- Fix domain and subdomain matching\n- Make SQL query more secure by avoiding string formatting\n- Many thanks to [Brandon Rhodes](https://github.com/brandon-rhodes) for 24c4234 !\n\n## 0.1.10\n\n- Read version to separate file so it can be imported in setup.py\n- Bugfix for python2 on linux\n\n## 0.1.9\n\n- Bugfix for python2 on linux\n\n## 0.1.8\n\n- Python2 support (thanks [dani14-96](https://github.com/dani14-96))\n\n## 0.1.7\n\n- Configurable cookies file (thanks [ankostis](https://github.com/ankostis))\n\n## 0.1.6\n\n- OSError instead of Exception for wrong OS.\n- Moved testing requirements to tox and travis-ci files.\n\n## 0.1.5\n\n- Updated to work better with PyPI's lack of markdown support\n- Working on tox and travis-ci integration\n- Added a few basic tests that should pass if one has Chrome installed and has visited my site (n8henrie.com)\n- Added sys.exit(0) if cookie_file not found so tests pass on travis-ci.\n\n## 0.1.0 (2015-02-25)\n\n- First release on PyPI.\n\n## Prior changelog from Gist\n\n- 20150221 v2.0.1: Now should find cookies for base domain and all subs.\n- 20140518 v2.0: Now works with Chrome's new encrypted cookies.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Borrow cookies from your browser's authenticated session for use in Python scripts.",
    "version": "0.6.0",
    "project_urls": {
        "homepage": "https://github.com/n8henrie/pycookiecheat"
    },
    "split_keywords": [
        "pycookiecheat",
        "chrome",
        "chromium cookies",
        "cookies",
        "firefox"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a69d2a1d045e1a75d7ef11c6a4e3c2d7413ab6fbe43ff3dc5372a4c502fa8989",
                "md5": "f4a0060df8cd8bac0d472b1d6b726e04",
                "sha256": "218c044bde5d3da8be7d1d4673aff53dff2e103ffa0f5b75d056e0c4a5f08638"
            },
            "downloads": -1,
            "filename": "pycookiecheat-0.6.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f4a0060df8cd8bac0d472b1d6b726e04",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 13801,
            "upload_time": "2023-09-22T21:28:07",
            "upload_time_iso_8601": "2023-09-22T21:28:07.974660Z",
            "url": "https://files.pythonhosted.org/packages/a6/9d/2a1d045e1a75d7ef11c6a4e3c2d7413ab6fbe43ff3dc5372a4c502fa8989/pycookiecheat-0.6.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b7f7333ba3db009d757f78959436c9d5b9d72ef3781f64ac1e650022ea7c57d6",
                "md5": "a38d1eb3b1147a5bd70faf219770d321",
                "sha256": "91c16fd569c50a7b2e8260576ec68ddbebe4ab89ea817b6dafe8f1c7a64a958e"
            },
            "downloads": -1,
            "filename": "pycookiecheat-0.6.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a38d1eb3b1147a5bd70faf219770d321",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 25634,
            "upload_time": "2023-09-22T21:28:09",
            "upload_time_iso_8601": "2023-09-22T21:28:09.795776Z",
            "url": "https://files.pythonhosted.org/packages/b7/f7/333ba3db009d757f78959436c9d5b9d72ef3781f64ac1e650022ea7c57d6/pycookiecheat-0.6.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-22 21:28:09",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "n8henrie",
    "github_project": "pycookiecheat",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "pycookiecheat"
}
        
Elapsed time: 0.12617s