赞
踩
selenium 通过js会被检测出来,按照其它设置:
- from selenium.webdriver import Chrome
- from selenium.webdriver import ChromeOptions
-
- option = ChromeOptions()
- option.add_experimental_option('excludeSwitches', ['enable-automation'])
- driver = Chrome(options=option)
设置 excludeSwitches 后window.navigator.webdriver true
不管用!!!
- option= ChromeOptions()
- option.add_experimental_option("excludeSwitches", ["enable-automation"])
- option.add_experimental_option('useAutomationExtension', False)
- driver = Chrome(executable_path=driver_path,options=option)
- driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {
- "source": """
- Object.defineProperty(navigator, 'webdriver', {
- get: () => undefined
- })
- """
- })
- driver.execute_cdp_cmd("Network.enable", {})
- driver.execute_cdp_cmd("Network.setExtraHTTPHeaders", {"headers": {"User-Agent": "browser1"}})
参考:
设置中增加
options.add_argument("--disable-blink-features=AutomationControlled")
效果:
没有配置前
配置后:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。