赞
踩
chrome_options.add_argument("disable-blink-features=AutomationControlled") # 就是这一行告诉chrome去掉了webdriver痕迹
- """初始化工作
- """
- path = r'D:\soft-tools\001\chromedriver'
- # 创建一个参数对象,用来控制chrome以无界面模式打开
- chrome_options = webdriver.ChromeOptions()
- chrome_options.add_experimental_option(
- "excludeSwitches", ["enable-automation"])
- chrome_options.add_experimental_option('useAutomationExtension', False)
- chrome_options.add_argument('lang=zh-CN,zh,zh-TW,en-US,en')
- chrome_options.add_argument(
- 'user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36')
- chrome_options.add_argument("disable-blink-features=AutomationControlled") # 就是这一行告诉chrome去掉了webdriver痕迹
-
- driver = webdriver.Chrome(executable_path=path,
- chrome_options=chrome_options,
- )
- # 设置隐性等待时间最长是30秒钟
- driver.implicitly_wait(10)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。