from selenium import webdriver
from time import sleep
import os
chrome_options = webdriver.ChromeOptions()
prefs = {"": “”}
prefs[“credentials_enable_service”] = False
prefs[“profile.password_manager_enabled”] = False
chrome_options.add_experimental_option(“prefs”, prefs) ##关掉密码弹窗
chrome_options.add_argument(’–disable-gpu’) # 谷歌文档提到需要加上这个属性来规避bug
chrome_options.add_argument(‘lang=zh_CN.UTF-8’) # 设置默认编码为utf-8
chrome_options.add_experimental_option(‘useAutomationExtension’, False) # 取消chrome受自动控制提示
chrome_options.add_experimental_option(“excludeSwitches”, [‘enable-automation’]) # 取消chrome受自动控制提示
browser = webdriver.Chrome(os.getcwd()+"\chromedriver.exe",0, options=chrome_options) # 参数的写入
browser.get(“https://www.baidu.com”)