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)
相关推荐
归去来 兮1 天前
Python爬虫爬取数据案例
开发语言·爬虫·python
何以解忧,唯有..1 天前
Python logging 模块:从入门到精通
python·microsoft·php
quantdash_cc1 天前
历史数据断层与REST请求慢到崩溃?QuantDash高性能量化数据API终极解决方案
开发语言·python·缓存·php·量化·quantdash
熊野君1 天前
Prompt / RAG / 规则 / Skills —— 定位、协作与实现路线
开发语言·python
zhangphil1 天前
Python Web后端框架FastAPI vs Flask
python·ai·llm
ly76891 天前
XML 从入门到实践:语法、命名空间、XPath、XSD 与 Java 安全解析
xml·java·python
winfredzhang1 天前
用 Python + wxPython 造一个照片工具箱:PDF / 加密ZIP / MP4 / 归档,以及我在这过程中踩到的 4 个坑
python·pdf·zip·mp4·移动
卷无止境1 天前
FastAPI 后台任务的边界,以及 Celery、Redis 与自建调度系统的选择
后端·python
卷无止境1 天前
Linux + Docker + FastAPI 工程化实践指南
后端·python·fastapi