赞
踩
现在不少大网站有对selenium采取了监测机制。比如正常情况下我们用浏览器访问淘宝等网站的 window.navigator.webdriver的值为
undefined。而使用selenium访问则该值为true。那么如何解决这个问题呢?
只需要设置Chromedriver的启动参数即可解决问题。在启动Chromedriver之前,为Chrome开启实验性功能参数excludeSwitches
,它的值为['enable-automation']
,完整代码如下:
- from selenium.webdriver import Chrome
- from selenium.webdriver import ChromeOptions
-
- option = ChromeOptions()
- option.add_experimental_option('excludeSwitches', ['enable-automation'])
- driver = Chrome(options=option)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。