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)
Search
from headless import SearchScraper, Headless
hl = Headless()
driver = hl.get_driver()
scraper = SearchScraper(driver=driver, max_results=5)
results = scraper.search("Nuhman PK github")
print(results)
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.9.tar.gz
(5.2 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.9.tar.gz.
File metadata
- Download URL: headless_driver-0.0.9.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86e3e644cd452bf8dedaf5f40812aaddd4df3c67f6219930e30ba45bcdaf0228
|
|
| MD5 |
6cfb0f820c39dd77ff3487b0bcc31774
|
|
| BLAKE2b-256 |
0eebef4d972b423bd8ce9d4a5de5a24c33885a51b5815a3cbb8a569af82b90a1
|
File details
Details for the file headless_driver-0.0.9-py3-none-any.whl.
File metadata
- Download URL: headless_driver-0.0.9-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b00593cb49df889b2071004e57e1d590d5416ce27d9399f75255dc7bd9d3803
|
|
| MD5 |
48dc041153c93d1a75708353e063d017
|
|
| BLAKE2b-256 |
81854c34e125c374876fdebaea012b5dc7843024fa0b641b085ffc892165bcd1
|