Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arnie97/chrome-cookiejar
Import your Chrome cookies to a Python CookieJar
https://github.com/arnie97/chrome-cookiejar
chrome chromium cookie web-scraping
Last synced: about 1 month ago
JSON representation
Import your Chrome cookies to a Python CookieJar
- Host: GitHub
- URL: https://github.com/arnie97/chrome-cookiejar
- Owner: Arnie97
- License: mit
- Created: 2016-07-28T16:11:07.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-12-06T22:41:37.000Z (about 3 years ago)
- Last Synced: 2024-11-14T21:28:44.194Z (about 2 months ago)
- Topics: chrome, chromium, cookie, web-scraping
- Language: Python
- Homepage:
- Size: 16.6 KB
- Stars: 19
- Watchers: 4
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Chrome Cookiejar
This module helps to utilize your Chrome cookies in Python scripts.
It's especially useful when scraping sites that requires login,
as you can test your ideas easily without solving the CAPTCHAs and emulating the whole login process.## Supported platforms
This package is only tested on Python 3.Please also note that values of cookies are encrypted with platform specific algorithms since Chrome 33.
The decrypt helper for Windows is already included; however, only older versions of Chrome is currently supported on macOS or Linux.## Get started
Use the following code snippet to create an instance of `http.cookiejar.CookieJar` that includes all cookies from your Chrome browser:```python
>>> from chrome_cookiejar import ChromeCookieJar
>>> cookiejar = ChromeCookieJar('/path/of/your/Cookies') # doctest: +SKIP```
The file path is optional; if omitted, the library will try to read cookies from the default user profile path of Chrom(ium).
If you're not sure, check `chrome://version` and follow the *Profile Path* shown here.As the `Cookies` file is a SQLite database, you could filter the host domain with SQL wildcards:
```python
>>> import requests, re
>>> jar = ChromeCookieJar(host_filter='%gith_b.com')
>>> login_user = re.compile(r'')
>>> login_user.findall(requests.get('https://github.com', cookies=None).text)
[]
>>> login_user.findall(requests.get('https://github.com', cookies=jar).text)
['Arnie97']```