chromesession
chromesession is a Python package that provides a convenient contextmanager for managing selenium chrome sessions.
In addition, a CachedSession is provided to directly cache the driver responses.
Installation
pip install chromesession
To use the chromesession.chrome context manager with selenium, the chromedriver must be installed on the system.
Alternatively, you can install the latest chromedriver as an extra.
pip install chromesession[driver]
Examples
Cache the specified URLs by fetching them via Selenium and saving the responses.
from pathlib import Path
from chromesession import CachedSession, chrome
def caching(*urls: str) -> Path:
"""
Cache the specified URLs by fetching them via Selenium and saving the responses.
"""
cachfile = "caching.sqlite"
with CachedSession(cache_name=cachfile) as session:
with chrome(verbose=False) as driver:
for url in urls:
if url in session:
print(f"{url=} already cached.")
continue
try:
driver.get(url)
session.save_driver(driver)
except Exception as e:
print(f"{url=} failed to cache: {e}", exc_info=True)
else:
print(f"{url=} saved in cache.")
return Path(cachfile)
if __name__ == "__main__":
caching("https://example.com/", "https://example.com/")
Dependencies
Extras
Install optional dependencies using extras.
| extra | installation | dependency |
|---|---|---|
| all | pip install chromesession[all] |
Install all extras. |
| driver | pip install chromesession[driver] |
|
| bs4 | pip install chromesession[bs4] |
Metadata
Release files for chromesession 0.1.3
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 |
|---|---|---|---|---|
| chromesession-0.1.3.tar.gz | 6.8 kB | Without provenance | Details for chromesession-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| chromesession-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for chromesession-0.1.3-py3-none-any.whl |
Total release size: 14.7 kB
Release files / chromesession-0.1.3.tar.gz
| Download URL | chromesession-0.1.3.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eb16899c50503b0a266bae110f00f80ab0df8d58b0d93cfdad6f749eeed9313c
|
|
BLAKE2b-256 checksum How to use checksums |
7dbc54888884accf4e74b320f1d7f20fb826d0c2813804bb6832276a17f52dd7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.13.7 Linux/6.11.0-1018-azure
|
Release files / chromesession-0.1.3-py3-none-any.whl
| Download URL | chromesession-0.1.3-py3-none-any.whl |
|---|---|
| Size | 7.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7601ca333e599a6aceed537d45a8e57c1792fb66b44f2417f61c3fd45c8c9b10
|
|
BLAKE2b-256 checksum How to use checksums |
83ff3948f43c1eea4e1797ffa69b74a2f719b32dfb4bf5bfdbd0b6a9b07c9dd3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.13.7 Linux/6.11.0-1018-azure
|
Security for chromesession 0.1.3
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.