谷歌浏览器114之前、131、132、133版本驱动下载,实时更新
114及更早版本
地址:chromedriver.storage.googleapis.com/index.html
113及113以后下载(打开json页面)
地址:googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json
131及以后的版本
地址:https://googlechromelabs.github.io/chrome-for-testing/
只有后面status是绿色对勾的才可以下载,只需点击版本名称即可跳转到对应的下载位置。
https://googlechromelabs.github.io/chrome-for-testing/
记一次使用selenium访问chromedriver提示一下错误:
c
正在启动 Chrome 浏览器... 无法启动 Chrome 浏览器: Message: session not created from unknown error: cannot find Chrome binary Stacktrace: GetHandleVerifier [0x00007FF6139560F5+28981] (No symbol) [0x00007FF6138B3E50] (No symbol) [0x00007FF61373916A] (No symbol) [0x00007FF613773AD8] (No symbol) [0x00007FF613771AED] (No symbol) [0x00007FF6137C5D98] (No symbol) [0x00007FF6137C5350] (No symbol) [0x00007FF6137B7743] (No symbol) [0x00007FF6137805A0] (No symbol) [0x00007FF613781853] GetHandleVerifier [0x00007FF613CA857D+3511741] GetHandleVerifier [0x00007FF613CBD6D2+3598098] GetHandleVerifier [0x00007FF613CB1E63+3550883] GetHandleVerifier [0x00007FF613A2492A+874858] (No symbol) [0x00007FF6138BE95F] (No symbol) [0x00007FF6138BA9C4] (No symbol) [0x00007FF6138BAB72] (No symbol) [0x00007FF6138AA199] BaseThreadInitThunk [0x00007FFAAA8D7614+20] RtlUserThreadStart [0x00007FFAAC7226A1+33]
Process finished with exit code 1
起初我的代码配置如下:
指定 ChromeDriver 的路径
c
# 指定 ChromeDriver 的路径
chrome_driver_path = r'C:\Program Files\Google\chromedriver-win64\chromedriver.exe' # 请替换为你的 ChromeDriver 路径
# 创建 ChromeDriver 服务
service = Service(chrome_driver_path)
# 打开浏览器
try:
print("正在启动 Chrome 浏览器...")
driver = webdriver.Chrome(service=service, options=chrome_options)
print("Chrome 浏览器启动成功!")
except Exception as e:
print(f"无法启动 Chrome 浏览器: {e}")
exit(1)
# 打开网页
print("正在打开网页...")
url = '' # 此处url可填自己访问的页面
try:
driver.get(url)
except Exception as e:
print(f"无法打开网页: {e}")
driver.quit()
exit(1)
print("网页打开成功!")
# 等待页面加载完成
time.sleep(5) # 可以根据需要调整等待时间
# 获取网页源代码
html = driver.page_source
print(html)
# 关闭浏览器
driver.quit()
然后运行以后报了以上的错误,接下来我的解决办法:
c
指定 ChromeDriver 的路径
chrome_driver_path = r'C:\Program Files\Google\chromedriver-win64\chromedriver.exe' # 请替换为你的 ChromeDriver 路径
# 指定 Chrome 浏览器的路径(增加了这个)
chrome_binary_path = r'C:\Program Files\Google\Chrome Dev\Application\chrome.exe' # 请替换为你的 Chrome 浏览器路径
# 创建 Chrome 选项
chrome_options = Options()
chrome_options.binary_location = chrome_binary_path
# 创建 ChromeDriver 服务
service = Service(chrome_driver_path)
或者直接把chromedriver.exe放到python安装目录下,就可以直接使用 driver = webdriver.Chrome()就可以了。