为什么chromedriver 117不能支持Chrome 117?

huangapple go评论148阅读模式
英文:

Why can't chromedriver 117 support Chrome 117?

问题

我正在尝试使用Selenium进行一些网页抓取。我试图使用Chrome和ChromeDriver 117,可以在这里下载。

但是,当我尝试执行脚本时,我收到以下错误消息:

错误 - 消息:未知错误:无法连接到127.0.0.1:38421上的Chrome

2023-08-03T15:14:09.917-03:00	会话未创建:此版本的ChromeDriver仅支持Chrome版本114

2023-08-03T15:14:09.917-03:00	当前浏览器版本为117.0.5926.0

为什么ChromeDriver只支持Chrome 114,而两者都是117版本?即使我使用116版本的两者也会出现相同的错误。

英文:

I'm trying to execute selenium to do some web scrapping. I'm trying to use the chrome & chromedriver 117, which are available for download here.

But when I try to execute the script, I get the following error:

ERROR - Message: unknown error: cannot connect to chrome at 127.0.0.1:38421

2023-08-03T15:14:09.917-03:00	from session not created: This version of ChromeDriver only supports Chrome version 114

2023-08-03T15:14:09.917-03:00	Current browser version is 117.0.5926.0

Why chromedriver only supports Chrome 114 if both are of version 117? And it's not exclusive for version 117, even if I use both of version 116 I get the same error.

答案1

得分: 1

错误消息...

错误 - 信息:未知错误:无法连接到 127.0.0.1:38421 上的 Chrome
2023-08-03T15:14:09.917-03:00 会话未创建:ChromeDriver 的此版本仅支持 Chrome 版本 114
2023-08-03T15:14:09.917-03:00 当前浏览器版本为 117.0.5926.0

...意味着 ChromeDriver 无法连接到 [tag:google-chrome] 二进制文件,因为存在 不兼容性 问题。

详情

尽管您使用的是 ChromeDriver v114.0,但您的 Google Chrome 版本为 117.0。因此存在不兼容性并出现错误。

使用 Selenium v4.6+ 版本的解决方法

如果您使用的是 Selenium v4.6 或更高版本,在这种情况下 Selenium Manager 可能会很有用。Selenium Manager 现在已完全集成到 Selenium 中,可以自动下载匹配的 ChromeDriver,您不必再显式指定 chromedriver 路径。因此,您的最小代码块可以是:

from selenium import webdriver

url = "https://google.com/"
driver = webdriver.Chrome()
driver.get(url)
英文:

This error message...

ERROR - Message: unknown error: cannot connect to chrome at 127.0.0.1:38421
2023-08-03T15:14:09.917-03:00   from session not created: This version of ChromeDriver only supports Chrome version 114
2023-08-03T15:14:09.917-03:00   Current browser version is 117.0.5926.0

...implies that ChromeDriver was unable to connect to the [tag:google-chrome] binary due to incompatibility issues.


Details

Though you are using ChromeDriver v114.0 but your Google Chrome version is 117.0. Hence the incompatibility and the error.


Solution with Selenium v4.6+ versions

In case you are using Selenium v4.6 or above, in such cases Selenium Manager can become handy. Selenium Manager is now fully integrated with Selenium and can silently download the matching ChromeDriver and you don't have to explicitly mention the chromedriver path anymore. So your minimal code block can be:

from selenium import webdriver

url = "https://google.com/"
driver = webdriver.Chrome()
driver.get(url)

huangapple
  • 本文由 发表于 2023年8月4日 02:20:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/76830708.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定