ChromeDriver版本不匹配问题的解决

今天运行一个以前写的爬虫程序,遇到如下错误:

python 复制代码
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 121
Current browser version is 133.0.6943.98 with binary path C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

这个错误表明你正在使用的 ChromeDriver 版本与 Google Chrome 浏览器 的版本不兼容。具体来说,你的 ChromeDriver 只支持 Chrome 121 ,但你的浏览器版本是 Chrome 133.0.6943.98 。因此,你需要更新 ChromeDriver 以匹配你的浏览器版本。

要下载最新版本的ChromeDriver,访问:Chrome for Testing availabilityhttps://googlechromelabs.github.io/chrome-for-testing/ 在这个页面,可以看到用于测试的Chrome和ChromeDriver。我们只需要下载和自己浏览器匹配的ChromeDriver(大版本匹配即可,不用考虑小版本号)。

将下载文件进行解压。

然后在Python程序中指定ChromeDriver路径即可。

python 复制代码
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
import csv

from time import sleep


 
# Chromedriver的路径
chromedriver_path = r"e:\chromedriver-win64\chromedriver.exe"

# 设置Chrome选项
options = webdriver.ChromeOptions()
options.add_experimental_option('detach', True)
相关推荐
岁月宁静12 小时前
五、《从零手撸 Agent》 — 什么是 Agent:从“会聊天”到“会做事”,差的就是一个循环
python·agent
梯度下降者13 小时前
Python - 函数
python·高阶函数·可调用对象·functools·嵌套作用域
starzy199015 小时前
深入理解Scala隐式参数:上下文流转
开发语言·python·scala
wuyk55516 小时前
Spider-第16讲-线程池与竞态问题
大数据·爬虫·python·elasticsearch·搜索引擎
kyle~1 天前
FastAPI --- 将业务能力以 API 的形式提供给外部系统
python·fastapi·前后端
aiotto资源分享1 天前
Python 写 JSON 文件,程序中途退出会留下什么?
java·python·json·jsondecodeerror
梯度下降者1 天前
Python信号量,条件变量,事件学习
python·条件变量·事件·信号量·线程通信
MSTcheng.1 天前
【AI应用实战】用 FastAPI + SSE 做一个自己的 AI 聊天网页:流式输出、多轮对话与完整源码
人工智能·python·大模型·fastapi·sse·ai聊天助手
the局外人1 天前
Python 实战检索优化:BM25、向量与重排
数据库·后端·python
__underline__1 天前
冷门Python知识点006篇:Python 类体里的名字,能被"凭空造出来"
后端·python