{"id":13625631,"url":"https://github.com/n8henrie/pycookiecheat","last_synced_at":"2025-05-14T09:07:25.524Z","repository":{"id":27754309,"uuid":"31242377","full_name":"n8henrie/pycookiecheat","owner":"n8henrie","description":"Borrow cookies from your browser's authenticated session for use in Python scripts.","archived":false,"fork":false,"pushed_at":"2025-01-04T15:02:34.000Z","size":261,"stargazers_count":774,"open_issues_count":0,"forks_count":109,"subscribers_count":30,"default_branch":"master","last_synced_at":"2025-04-03T18:09:31.963Z","etag":null,"topics":["chrome","cookies","python3","requests"],"latest_commit_sha":null,"homepage":"https://n8henrie.com/2013/11/use-chromes-cookies-for-easier-downloading-with-python-requests/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"alex/what-happens-when","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/n8henrie.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.md","dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["n8henrie"],"custom":["https://n8henrie.com/donate"],"patreon":"n8henrie","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":"n8henrie","issuehunt":null,"otechie":null}},"created_at":"2015-02-24T03:02:18.000Z","updated_at":"2025-04-02T11:55:05.000Z","dependencies_parsed_at":"2023-11-28T23:27:22.393Z","dependency_job_id":"1a964c32-2cf4-4882-8515-311a3daa7207","html_url":"https://github.com/n8henrie/pycookiecheat","commit_stats":{"total_commits":385,"total_committers":17,"mean_commits":"22.647058823529413","dds":"0.17402597402597397","last_synced_commit":"278a3cd08ca2ab6a98592ebf4281c8fb4dce1cc1"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n8henrie%2Fpycookiecheat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n8henrie%2Fpycookiecheat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n8henrie%2Fpycookiecheat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n8henrie%2Fpycookiecheat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/n8henrie","download_url":"https://codeload.github.com/n8henrie/pycookiecheat/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248330673,"owners_count":21085759,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chrome","cookies","python3","requests"],"created_at":"2024-08-01T21:01:58.589Z","updated_at":"2025-04-11T02:38:24.130Z","avatar_url":"https://github.com/n8henrie.png","language":"Python","funding_links":["https://github.com/sponsors/n8henrie","https://n8henrie.com/donate","https://patreon.com/n8henrie","https://liberapay.com/n8henrie"],"categories":["Python","Python (1887)"],"sub_categories":[],"readme":"# 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](https://n8henrie.com/2013/11/use-chromes-cookies-for-easier-downloading-with-python-requests/)\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 \u003c v0.4.0. pycookiecheat \u003e= v0.4.0 requires\nPython 3 and in general will aim to support python versions that are stable and\nnot yet end-of-life: \u003chttps://devguide.python.org/versions\u003e.\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### As a Command-Line Tool\n\nAfter installation, the CLI tool can be run as a python module `python -m` or\nwith a standalone console script:\n\n```console\n$ python -m pycookiecheat --help\nusage: pycookiecheat [-h] [-b BROWSER] [-o OUTPUT_FILE] [-v] [-c COOKIE_FILE]\n                     [-V]\n                     url\n\nCopy cookies from Chrome or Firefox and output as json\n\npositional arguments:\n  url\n\noptions:\n  -h, --help            show this help message and exit\n  -b BROWSER, --browser BROWSER\n  -o OUTPUT_FILE, --output-file OUTPUT_FILE\n                        Output to this file in netscape cookie file format\n  -v, --verbose         Increase logging verbosity (may repeat), default is\n                        `logging.ERROR`\n  -c COOKIE_FILE, --cookie-file COOKIE_FILE\n                        Cookie file\n  -V, --version         show program's version number and exit\n\n```\n\nBy default it prints the cookies to stdout as JSON but can also output a file in\nNetscape Cookie File Format.\n\n### As a Python Library\n\n```python\nfrom pycookiecheat import BrowserType, get_cookies\nimport requests\n\nurl = 'https://n8henrie.com'\n\n# Uses Chrome's default cookies filepath by default\ncookies = get_cookies(url)\nr = requests.get(url, cookies=cookies)\n\n# Using an alternate browser\ncookies = get_cookies(url, browser=BrowserType.CHROMIUM)\n```\n\nUse the `cookie_file` keyword-argument to specify a different path to the file\ncontaining your cookies:\n`get_cookies(url, cookie_file='/abspath/to/cookies')`\n\nYou may be able to retrieve cookies for alternative Chromium-based browsers by\nmanually specifying something like\n`\"/home/username/.config/BrowserName/Default/Cookies\"` as your `cookie_file`.\n\n## Features\n\n- Returns decrypted cookies from Google Chrome, Brave, or Slack, on MacOS 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 \u003cv0.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 (unreleased) master branch with pip?\n\n- `python -m pip install git+https://github.com/n8henrie/pycookiecheat@master`\n\n## Buy Me a Coffee\n\n[☕️](https://n8henrie.com/donate)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fn8henrie%2Fpycookiecheat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fn8henrie%2Fpycookiecheat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fn8henrie%2Fpycookiecheat/lists"}