An enhanced Chrome WebDriver with anti-detection capabilities for web scraping and automation tasks, built on Selenium with additional stealth features.
- 🛡️ Anti-detection techniques to bypass common bot detection systems
- 🌐 Network monitoring with performance logging capabilities
- 🍪 Cookie management with multiple output formats
- 💾 LocalStorage access for comprehensive data collection
- 🖥️ Headless mode support with optimized default configurations
- 🕵️ Stealth configurations via selenium-stealth integration
- ✅ Fully tested with comprehensive unit tests (including logger tests)
- 📊 Code coverage tracking (100% coverage)
- ⚙️ Config class for centralized configuration management
- 🔄 Object initialization via
from_objmethod
- Python 3.11 or higher
- Chrome or Chromium browser installed
pip install git+https://github.com/a-ulianov/undetected-chrome-driver.git-
Clone the repository:
git clone https://github.com/a-ulianov/undetected-chrome-driver.git cd undetected-chrome-driver -
Install dependencies:
pip install -r requirements.txt
from src.undetected_chrome_driver import UndetectedChromeDriver
with UndetectedChromeDriver() as driver:
driver.get('https://example.com')
print(driver.title)from src.undetected_chrome_driver import UndetectedChromeDriver, Config
# Using Config class
config = Config()
driver = UndetectedChromeDriver.from_obj(config)
with driver:
driver.get('https://example.com')
# Access all features
cookies = driver.get_cookies(as_dict=True)
requests = driver.get_sent_requests()
local_storage = driver.get_local_storage()
cookie_header = driver.get_cookie_header()from src.undetected_chrome_driver import Logger
# Custom logger setup
logger = Logger(
logger_name="custom_logger",
logging_level=logging.DEBUG,
log_to_file=True,
logs_dir="custom_logs",
log_file="custom.log"
)| Parameter | Type | Default | Description |
|---|---|---|---|
user_agent |
str | Default UA string | Custom user agent string |
chrome_driver_options |
List[str] | Default options | Additional Chrome options |
enable_performance_logging |
bool | False | Enable network request logging |
from_obj(obj: Any) -> UndetectedChromeDriver: Creates instance from object attributesget_sent_requests() -> List[dict]: Returns network request logsget_cookies(as_dict=False) -> Union[List[dict], dict]: Returns cookies in specified formatget_cookie_header() -> str: Returns cookies formatted for HTTP headersget_local_storage() -> dict: Returns browser's local storage contents
Centralized configuration for driver settings including:
- User agent
- Chrome options
- Performance logging
- Logger configuration
Customizable logger with:
- Console and file output
- Configurable logging levels
- Timestamp and format customization
your_project/
├── src/
│ ├── undetected_chrome_driver/
│ │ ├── __init__.py
│ │ ├── driver.py
│ │ ├── logger.py
│ │ └── config.py
├── tests/
│ ├── conftest.py
│ ├── test_driver.py
│ └── test_logger.py
├── pyproject.toml
├── requirements.txt
└── main.py
pytest tests/ --cov=src --cov-report=htmlOr use the provided main script:
python main.pyContributions are welcome! Please follow these steps:
- Fork the repository
- Create a new branch (
git checkout -b feature/your-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin feature/your-feature) - Create a new Pull Request
MIT License - see LICENSE for details.
- Selenium team for the base WebDriver implementation
- Undetected Chromedriver for anti-detection techniques
- Selenium Stealth for additional stealth configurations