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)
相关推荐
TechWayfarer1 小时前
查询IP所在地的3种方案:从API到离线库,风控场景怎么选?
开发语言·网络·python·网络协议·tcp/ip
程序员榴莲1 小时前
Python 单例模式
开发语言·python·单例模式
hh.h.2 小时前
昇腾CANN ops-transformer 仓的 MC2 算子:MoE 模型的全到全通信
python·深度学习·transformer·cann
NiceCloud喜云3 小时前
Claude Files API 深入:从上传、复用到配额管理的工程化指南
android·java·数据库·人工智能·python·json·飞书
专注VB编程开发20年3 小时前
windows下python自带标准库 ≈ 70% 纯.py 源码,30% .pyd(DLL)
python
萌新小码农‍4 小时前
人工智能数学基础+python实例(人工智能学习day3)
开发语言·人工智能·python
毋语天5 小时前
FastAPI 进阶实战:请求体、文件上传、响应模型与数据校验
python·fastapi·api开发·数据校验·pydantic
ZhengEnCi6 小时前
09a-斯坦福 CS336 作业一:BPE 分词器
python·神经网络
测试员周周6 小时前
【Appium 系列】第18节-重试与容错 — 移动端测试的稳定性保障
人工智能·python·功能测试·ui·单元测试·appium·测试用例