版本下载

https://www.cnblogs.com/CCWind/p/17713440.html
https://googlechromelabs.github.io/chrome-for-testing/#stable

启动参数

# 实例化Chrome类,与webdriver建立连接,启动一个非常干净的谷歌浏览器,不带任何用户配置信息
browser = webdriver.Chrome(service_args=["--verbose"], service_log_path="D:\\Python37-32\chrome_server.log")

Chromeoption类说明

https://blog.51cto.com/xfxuezhang/5858991

#可通过添加配置文件,让开启的google浏览器记住配置数据,比如cookies等
#options.add_argument(r"user-data-dir=C:\Users\Administrator\AppData\Local\Google\Chrome\User Data"

错误

  • TypeError: WebDriver.init() got multiple values for argument options
说明: Selenium从4.10以后不再支持executeable_path参数了,需要使用service参数代替
from selenium import webdriver
from selenium.webdriver.chrome.service import Service


chromedriver_path = "chromedriver.exe"
chrome_options = webdriver.ChromeOptions()
browser = webdriver.Chrome(service=Service("chromedriver.exe"), options=chrome_options)