undetected-chromedriver/README.md

62 lines
1.4 KiB
Markdown
Raw Normal View History

2019-12-22 06:15:59 -07:00
# undetected_chromedriver
2019-12-22 06:11:07 -07:00
2020-05-12 11:42:15 -06:00
https://github.com/ultrafunkamsterdam/undetected-chromedriver
2019-12-22 06:11:07 -07:00
Optimized Selenium Chromedriver patch which does not trigger anti-bot services like Distill Network.
Automatically downloads the driver binary and patches it.
2020-01-02 01:55:42 -07:00
2020-05-20 13:26:11 -06:00
* **Tested on version 75,76,77,78,79,80,81,83**
2020-01-02 01:55:42 -07:00
2020-05-12 11:42:15 -06:00
* **patching also works on MS Edge (chromium-based) webdriver binary**
2019-12-22 06:11:07 -07:00
2020-01-02 01:55:42 -07:00
2019-12-22 06:47:16 -07:00
## Installation ##
```
pip install git+https://github.com/ultrafunkamsterdam/undetected-chromedriver.git
```
2019-12-22 06:11:07 -07:00
2019-12-22 06:47:41 -07:00
## Usage ##
2019-12-22 06:15:59 -07:00
2019-12-22 06:19:55 -07:00
#### the easy way (recommended) ####
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:47:41 -07:00
2019-12-22 06:19:55 -07:00
#### patches selenium module ####
Needs to be done before importing from selenium package
2019-12-22 06:15:59 -07:00
```python
import undetected_chromedriver as uc
uc.install()
2019-12-22 06:11:07 -07:00
from selenium.webdriver import Chrome
driver = Chrome()
driver.get('https://distilnetworks.com')
2019-12-22 06:15:59 -07:00
````
2019-12-22 06:47:41 -07:00
2019-12-22 06:19:55 -07:00
#### the customized way ####
2019-12-22 06:15:59 -07:00
```python
import undetected_chromedriver as uc
2019-12-22 06:15:59 -07:00
2019-12-22 06:11:07 -07:00
#specify chromedriver version to download and patch
#this did not work correctly until 1.2.1
uc.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',
)
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:47:41 -07:00