2019-12-22 06:15:59 -07:00
|
|
|
# undetected_chromedriver
|
2019-12-22 06:11:07 -07:00
|
|
|
|
|
|
|
BY ULTRAFUNKAMSTERDAM (https://github.com/ultrafunkamsterdam)
|
|
|
|
|
|
|
|
Optimized Selenium Chromedriver patch which does not trigger anti-bot services like Distill Network.
|
|
|
|
Automatically downloads the driver binary and patches it.
|
|
|
|
Not tested on Chrome higher than 79!
|
|
|
|
|
|
|
|
|
2019-12-22 06:16:34 -07:00
|
|
|
## USAGE
|
2019-12-22 06:15:59 -07:00
|
|
|
|
|
|
|
|
2019-12-22 06:16:34 -07:00
|
|
|
# 1- by far the easiest
|
2019-12-22 06:15:59 -07:00
|
|
|
```python
|
2019-12-22 06:11:07 -07:00
|
|
|
from undetected_chromedriver import Chrome, ChromeOptions
|
|
|
|
driver = Chrome()
|
|
|
|
driver.get('https://distilnetworks.com')
|
2019-12-22 06:15:59 -07:00
|
|
|
```
|
|
|
|
|
2019-12-22 06:16:34 -07:00
|
|
|
# 2- patches selenium module (before importing from selenium!)
|
2019-12-22 06:15:59 -07:00
|
|
|
```python
|
2019-12-22 06:11:07 -07:00
|
|
|
import undetected_chromedriver
|
|
|
|
undetected_chromedriver.install()
|
|
|
|
from selenium.webdriver import Chrome
|
|
|
|
driver = Chrome()
|
|
|
|
driver.get('https://distilnetworks.com')
|
2019-12-22 06:15:59 -07:00
|
|
|
````
|
|
|
|
|
2019-12-22 06:16:34 -07:00
|
|
|
# 3 - Customized
|
2019-12-22 06:15:59 -07:00
|
|
|
```python
|
2019-12-22 06:11:07 -07:00
|
|
|
import undetected_chromedriver
|
2019-12-22 06:15:59 -07:00
|
|
|
|
2019-12-22 06:11:07 -07:00
|
|
|
#specify chromedriver version to download and patch
|
|
|
|
undetected_chromedriver.TARGET_VERSION = 78
|
2019-12-22 06:15:59 -07:00
|
|
|
|
2019-12-22 06:11:07 -07:00
|
|
|
# or specify your own chromedriver binary to patch
|
|
|
|
undetected_chromedriver.install(
|
|
|
|
executable_path='c:/users/user1/chromedriver.exe',
|
|
|
|
target_version=78
|
|
|
|
)
|
|
|
|
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')
|
2019-12-22 06:15:59 -07:00
|
|
|
```
|
|
|
|
|
2019-12-22 06:16:34 -07:00
|
|
|
# 4- a combination of function(s) from this module :)
|