Undetected ChromeDriver

3.5.5 · active · verified Sun Apr 12

Undetected ChromeDriver is a Python library that serves as a `selenium.webdriver.Chrome` replacement, optimized to bypass anti-bot detection systems like Cloudflare, Imperva, and DataDome. It automatically downloads and patches the appropriate ChromeDriver binary for the installed Chrome version. The library is actively maintained, with version 3.5.5 being the latest stable release, and it offers ongoing efforts to understand and counter detection algorithms.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize `undetected-chromedriver`, navigate to a website that performs bot detection, and verify successful access by printing the page title and saving a screenshot. It includes best practices for resource cleanup and stability.

import undetected_chromedriver as uc
import time
import os

# Create an undetected Chrome instance
# use_subprocess=True is often recommended for stability
# and to avoid issues with ChromeDriver matching.
driver = uc.Chrome(use_subprocess=True)

try:
    # Navigate to a website known for bot detection checks
    driver.get("https://nowsecure.nl")

    # Give it some time to load and for anti-bot measures to potentially resolve
    time.sleep(5)

    # Print the page title to verify
    print(f"Page title: {driver.title}")

    # Optionally take a screenshot
    screenshot_path = "nowsecure_screenshot.png"
    driver.save_screenshot(screenshot_path)
    print(f"Screenshot saved to {screenshot_path}")

except Exception as e:
    print(f"An error occurred: {e}")

finally:
    # Always ensure the driver is quit to clean up resources
    driver.quit()
    print("Browser closed.")

view raw JSON →