reqdriver
A Python package that seamlessly transfers a requests.Session to a Selenium WebDriver, maintaining session cookies and proxy settings. Ideal for web scraping and automated browsing with pre-established session states.
Features
- Transfer Session Cookies: Easily transfer cookies from a
requests.Sessionto a Selenium WebDriver. - Proxy Integration: Set up a Chrome WebDriver with the same proxy settings as your
requests.Session. - Flexible WebDriver Management: Use an existing WebDriver instance or let reqdriver create one for you.
- Custom WebDriver Options: Customize your WebDriver with additional options.
Installation
pip install reqdriver
Usage
Basic Usage
Import the RequestsDriver class from the reqdriver package:
from reqdriver import RequestsDriver
import requests
Transferring Cookies
Transfer cookies from a requests.Session:
session = requests.Session()
session.cookies.set('test_cookie', '12345', domain='example.com')
req_driver = RequestsDriver(session)
req_driver.set_cookies('http://example.com')
driver = req_driver.get_driver()
driver.get('http://example.com')
Setting Proxies
Set up a WebDriver with the same proxy settings as your requests.Session:
session = requests.Session()
session.proxies = {
'http': 'http://192.168.3.2:8080'
}
req_driver = RequestsDriver(session)
driver = req_driver.get_driver()
driver.get('http://example.com')
Using Custom WebDriver Options
Pass your custom Chrome WebDriver options:
from selenium.webdriver.chrome.options import Options
custom_options = Options()
custom_options.add_argument('--headless')
session = requests.Session()
req_driver = RequestsDriver(session, custom_options=custom_options)
driver = req_driver.get_driver()
driver.get('http://example.com')
Using Existing WebDriver
Pass your already created WebDriver instance:
from selenium import webdriver
existing_driver = webdriver.Chrome(executable_path='path_to_chromedriver')
session = requests.Session()
req_driver = RequestsDriver(session, driver=existing_driver)
req_driver.set_cookies('http://example.com')
existing_driver.get('http://example.com')
Contributing
Contributions are welcome! Feel free to open issues or submit pull requests.
License
Distributed under the MIT License. See LICENSE for more information.
My links
Metadata
Release files for reqdriver 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| reqdriver-0.1.2.tar.gz | 4.9 kB | Without provenance | Details for reqdriver-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| reqdriver-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for reqdriver-0.1.2-py3-none-any.whl |
Total release size: 10.2 kB
Release files / reqdriver-0.1.2.tar.gz
| Download URL | reqdriver-0.1.2.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
424d5e4bdb003235c54ecc2798eba19f60eb03a8980b8e649427a0e6bef79073
|
|
BLAKE2b-256 checksum How to use checksums |
52318cb580198398671b329ffd464a32e576e1369652647dee7e586fb34cfe89
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.0
|
Release files / reqdriver-0.1.2-py3-none-any.whl
| Download URL | reqdriver-0.1.2-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3093dd17d25244642e7e5eeae0976457dbb16448260fba171d88556d28e9e153
|
|
BLAKE2b-256 checksum How to use checksums |
481a07bec935b369da7a269ecb8b2aa27f0eca2ac896d53a1042a1dbd9de7309
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.0
|
Security for reqdriver 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.