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)
相关推荐
sylviiiiiia3 小时前
leetcode hot100
python·算法·leetcode
千里码aicood3 小时前
flask-基于注意力机制的异常流量检测与自动防御系统
后端·python·flask
维克兜率天3 小时前
4.3.2.1 日常监控:上线只是开始
服务器·数据库·python·区块链·php·量化
the局外人3 小时前
学习 FastAPI 的 Day 2:用异步 ORM 完成增删改查
后端·python·fastapi
智搜广告3 小时前
GEO优化公司怎么选?智搜广告从三个维度帮你判断
大数据·人工智能·python·elasticsearch·microsoft·geo
wanglei2007084 小时前
软件架构设计中,各个组件之间的通信方式有哪些?
python
会飞的拖把4 小时前
Python 面向对象编程详解:从类与对象到动态属性方法
开发语言·python
微小冷4 小时前
Python CasADi初步教程
python·控制·模型预测·casadi·符号表达式·sx
cpolar技术支持4 小时前
requirements.txt 能安装不等于安全:用 pip-audit 检查 Python 依赖,cpolar 临时分享脱敏报告
python·cpolar·requirements·依赖安全·pip-audit
测试19985 小时前
Jmeter接口自动化生成测试报告html格式详解
自动化测试·python·测试工具·jmeter·职场和发展·测试用例·接口测试