A simple Python package for managing Selenium Chrome drivers in headless mode.
Project description
headless-driver
A simple Python package for managing Selenium Chrome drivers in headless mode.
Features
- Headless Chrome driver management
- Temporary user data directory
- Custom window size and user agent
- Easy cleanup and context manager support
- Remote and local driver support
Installation
pip install headless-driver
Usage
from headless import Headless
hl = Headless()
driver = hl.get_driver()
driver.get("https://example.com")
print(driver.title)
hl.quit()
Or use as a context manager:
from headless import Headless
with Headless() as driver:
driver.get("https://example.com")
print(driver.title)
API Documentation
Headless class
Headless(
user_data_dir: Optional[str] = None,
window_size: Tuple[int, int] = (1920, 1080),
user_agent: Optional[str] = None,
headless: bool = True,
chrome_driver_path: Optional[str] = '/opt/homebrew/bin/chromedriver',
additional_args: Optional[List[str]] = None,
remote_url: Optional[str] = None,
)
user_data_dir: Path for Chrome user data (temporary if not provided)window_size: Browser window size (default: 1920x1080)user_agent: Custom user agent stringheadless: Run Chrome in headless mode (default: True)chrome_driver_path: Path to chromedriver executableadditional_args: List of extra Chrome argumentsremote_url: Use remote Selenium server if provided
Methods
get_driver(): Returns a Selenium WebDriver instancequit(): Quits the driver and cleans up user data
Running Tests
python -m unittest discover tests
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
headless_driver-0.0.4.tar.gz
(4.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file headless_driver-0.0.4.tar.gz.
File metadata
- Download URL: headless_driver-0.0.4.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ccfe942abe0a43c9ff47ce2f4e7324513c952d758805e4f9109cff6f0d1d356
|
|
| MD5 |
c3a2a8b624b755fd9513355b79c46be4
|
|
| BLAKE2b-256 |
28f5a090dba0432d35f5f96a68e97934b812485cab3cd051aa327c3405c04f36
|
File details
Details for the file headless_driver-0.0.4-py3-none-any.whl.
File metadata
- Download URL: headless_driver-0.0.4-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
056026a5c573e19d7c01b4ac5386a7fd72901440b880159119465849df7aeab5
|
|
| MD5 |
7abf43a97886acaa1e96827f665a498d
|
|
| BLAKE2b-256 |
72cc7880a6cd4304e86a35ceb598156d734ddc8c95658c904433afd8c9866430
|