python 3.7
selenium 3.14.1
urllib3 1.26.8
Google Chrome 119.0.6045.160 (64位)
chromedriver.exe 119.0.6045.105(win32)
1 Google Chrome 添加参数 "--remote-debugging-port=9222"
2 测试效果(chromedriver.exe 要和 Google Chrome 版本一致 )
最新版 chromedriver.exe 下载地址
Chrome for Testing availability
测试代码:
from selenium import webdriver
# 谷歌浏览器位置
CHROME_PATH = r'C:\Program Files\Google\Chrome\Application\chrome.exe'
# 谷歌浏览器驱动地址
CHROMEDRIVER_PATH = r'.\chromedriver.exe'
chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
chrome_options.binary_location = CHROME_PATH
driver = webdriver.Chrome(executable_path = CHROMEDRIVER_PATH, options=chrome_options)
driver.get("https://www.baidu.com/")
print(driver.title)