现象:
代码:
# coding=utf-8 from selenium import webdriver driver = webdriver.Chrome() driver.get("https://www.so.com/") driver.maximize_window()
解决方案:在浏览器配置里添加参数
chrome_options = webdriver.ChromeOptions() chrome_options.add_experimental_option("excludeSwitches", [‘enable-automation‘]) #调用浏览器 driver = webdriver.Chrome(options=chrome_options)
具体代码:
# coding=utf-8 from selenium import webdriver
chrome_options = webdriver.ChromeOptions() chrome_options.add_experimental_option("excludeSwitches", [‘enable-automation‘])
driver = webdriver.Chrome(options=chrome_options) driver.get("https://www.so.com/") driver.maximize_window()
运行后就不显示提示了: