selenium circumvent Website Monitoring

Evade Website Monitoring

Many large sites have now adopted a monitoring mechanism for selenium. For example, under normal circumstances we visit window.navigator.webdriver Taobao and other sites is undefined browser. Selenium is used to access the value is true. So how to solve this problem?

Only you need to set the Chromedriverstartup parameters to solve the problem. Starting Chromedriverbefore the turn of the Chrome experimental feature parameters excludeSwitches, it is ['enable-automation'], complete code is as follows:

import time
from selenium import webdriver
from selenium.webdriver import ChromeOptions  # 需要导入的类
# 创建 option 对象
option = ChromeOptions()
option.add_experimental_option('excludeSwitches', ['enable-automation'])
# 创建浏览器对象
driver = webdriver.Chrome(options=option)
driver.implicitly_wait(10)
driver.get('https://www.taobao.com/')
print(driver.title)  # 淘宝网 - 淘!我喜欢
time.sleep(2)
driver.quit()

Guess you like

Origin www.cnblogs.com/Nayears/p/12177662.html