让selenium规避网站的检测

在使用selenium对某些网站模拟访问的时候会被检测出来,检测出来之后就有可能拿不到我们想要的数据,那么我们怎么可以规避掉呢?

在使用谷歌浏览器的时候我们右键-检查-console-输入window.navigator.webdriver假如返回的是True则是被检测出了了,返回的是undefined则没检测到。

from selenium import webdriver
from selenium.webdriver import ChromeOptions
option = ChromeOptions()
option.add_experimental_option('excludeSwitches', ['enable-automation'])

#实例化一个浏览器对象
bro = webdriver.Chrome(executable_path='your driver path',options=option)
bro.get('https://www.taobao.com/')
原文地址:https://www.cnblogs.com/blackball9/p/11979660.html