from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
options = webdriver.ChromeOptions()
#关闭提示消息
# options.add_argument('disable-infobars') #若不管用,可使用如下参数
options.add_experimental_option("excludeSwitches", ['enable-automation']);
#设置下载地址/ 禁用浏览器弹窗
download_path = r"***"
prefs = {'download.default_directory': download_path,
'safebrowsing.enabled': True,
}
options.add_experimental_option('prefs', prefs)
# 获取谷歌浏览器所有控制台信息
des = DesiredCapabilities.CHROME
des['loggingPrefs'] = {'performance': 'ALL'}
#设置启动语言
# options.add_argument("--lang=en_US");
options.add_argument("--lang=zh-CN");
#
options.add_argument('--safebrowsing-disable-download-protection')
options.add_argument("--safebrowsing-disable-extension-blacklist")
driver = webdriver.Chrome(options=options)
driver.get("https://www.baidu.com/")
# 其他参考:
# https://zhuanlan.zhihu.com/p/60852696
# https://www.jb51.net/article/182967.htm
# https://blog.csdn.net/QYQ08409121/article/details/100547001
#C:\Users\***\AppData\Local\Google\Chrome\User Data\FileTypePolicies\43
设置selenium启动谷歌浏览器参数
最新推荐文章于 2024-08-04 12:19:09 发布