Skip to main content

Optimized Selenium/Chromedriver drop-in replacement for selenium.webdriver, using the same interface for Chrome and ChromeOptions, but which does NOT trigger anti-bot services like Distil / Imperva / DataDome / Botprotect.io and such. All required anti-detection settings are built-in, yet overridable if you'd really want. Be aware: any customization in settings could potentially trigger detection, For more information check out the README.

Project description

undetected_chromedriver

https://github.com/ultrafunkamsterdam/undetected-chromedriver

Optimized Selenium Chromedriver patch which does not trigger anti-bot services like Distill Network / Imperva / DataDome / Botprotect.io Automatically downloads the driver binary and patches it.

  • Tested on version 75,76,77,78,79,80,81,83,84,85,86

  • patching also works on MS Edge (chromium-based) webdriver binary

New

By default, the console log function is disabled to prevent certain detections. Until a cleaner solution is found, use the following to manually enable it

import undetected_chromedriver as uc
driver = uc.Chrome(enable_console_log=True)

Installation

pip install undetected-chromedriver

Usage

To prevent unnecessary hair-pulling and issue-rasing, please mind the important note at the end of this document .


the easy way (recommended)

import undetected_chromedriver as uc
driver = uc.Chrome()
driver.get('https://distilnetworks.com')

# To target specific version

import undetected_chromedriver as uc
uc.TARGET_VERSION = 85
driver = uc.Chrome()

patches selenium module

Needs to be done before importing from selenium package

import undetected_chromedriver as uc
uc.install()
from selenium.webdriver import Chrome
driver = Chrome()
driver.get('https://distilnetworks.com')

the customized way

import undetected_chromedriver as uc

#specify chromedriver version to download and patch
#this did not work correctly until 1.2.1
uc.TARGET_VERSION = 78    

# or specify your own chromedriver binary to patch
undetected_chromedriver.install(
    executable_path='c:/users/user1/chromedriver.exe',
)
from selenium.webdriver import Chrome, ChromeOptions
opts = ChromeOptions()
opts.add_argument(f'--proxy-server=socks5://127.0.0.1:9050')
driver = Chrome(options=opts)
driver.get('https://distilnetworks.com')

datadome.co

These guys have actually a powerful product, and a link to this repo, which makes me wanna test their product. Make sure you use a "clean" ip for this one.

# STANDARD chromedriver
from selenium import webdriver
chrome = webdriver.Chrome()
chrome.get('https://datadome.co/customers-stories/toppreise-ends-web-scraping-and-content-theft-with-datadome/')
chrome.save_screenshot('datadome_regular_webdriver.png')
True  
# after this detectioon, you'll keep being nagged with puzzles, even if you use another machine from the same same network (they use a very tight but effective regime, possibly combination of fingerprinting and ip-flagging).


# UNDETECTED chromedriver (headless,even)

import undetected_chromedriver as uc
options = uc.ChromeOptions()
options.headless=True
options.add_argument('--headless')
chrome = uc.Chrome(options=options)
chrome.get('https://datadome.co/customers-stories/toppreise-ends-web-scraping-and-content-theft-with-datadome/')
chrome.save_screenshot('datadome_undetected_webddriver.png')

Check both saved screenhots here

important note

the default blank page on start plays a BIG role in the anti-detection workings of the module. You will only become undetectable from the moment you use driver.get(url) to navigate to some url (and next and next and next). This automatically means that if you enter a url in the browser screen by hand right after launch, you are NOT protected! New Tabs: same story. If you really need multi-tabs, then open the tab with the blank page (hint: url is data:, including comma, and yes, driver accepts it) and do your thing as usual. If you follow these "rules" (actually its default behaviour), then you will have a great time for now.

TL;DR and for the visual-minded:

In [1]: import undetected_chromedriver as uc
In [2]: driver = uc.Chrome()
In [3]: driver.execute_script('return navigator.webdriver')
Out[3]: True  # Detectable
In [4]: driver.get('https://distilnetworks.com') # starts magic
In [4]: driver.execute_script('return navigator.webdriver')
In [5]: None  # Undetectable!

end important note

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

undetected-chromedriver-1.4.0.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

undetected_chromedriver-1.4.0-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file undetected-chromedriver-1.4.0.tar.gz.

File metadata

  • Download URL: undetected-chromedriver-1.4.0.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.8.1

File hashes

Hashes for undetected-chromedriver-1.4.0.tar.gz
Algorithm Hash digest
SHA256 fbdabd6658facfaddced6ecc9dbe34211c1e8854e509d08d12d67f4e55e87c78
MD5 0554c3850ef7fe919f970d3052e03dbe
BLAKE2b-256 de04404b7ea08df8e1829d156ed153750093dd596306548ff8c10821af30d330

See more details on using hashes here.

File details

Details for the file undetected_chromedriver-1.4.0-py3-none-any.whl.

File metadata

  • Download URL: undetected_chromedriver-1.4.0-py3-none-any.whl
  • Upload date:
  • Size: 18.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.8.1

File hashes

Hashes for undetected_chromedriver-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 39d4e2058366e16a328875d02cd6a7c860a5b372f4ad32ae5674509eec9ac884
MD5 13f7bc2e95e1514981a26c4ba572c9a4
BLAKE2b-256 c909ab91b0d5b6c3b3b8786d0634c2a77c4d2d62a42a240069e22b1f4cf97da0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page