selenium:chromedriver与chrome版本的对应关系

Posted whist

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了selenium:chromedriver与chrome版本的对应关系相关的知识,希望对你有一定的参考价值。

今天想用Python实现一个自动刷新网页的脚本,需要用到selenium。
因为刚开始没有指定chromedriver,所以报错:

Traceback (most recent call last):
  File "D:\Anaconda3\lib\site-packages\selenium\webdriver\common

\service.py", line 76, in start
    stdin=PIPE)
  File "D:\Anaconda3\lib\subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "D:\Anaconda3\lib\subprocess.py", line 997, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] 系统找不到指定的文件。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "f5.py", line 5, in <module>
  File "D:\Anaconda3\lib\site-packages\selenium\webdriver\chrome

\webdriver.py", line 68, in __init__
    self.service.start()
  File "D:\Anaconda3\lib\site-packages\selenium\webdriver\common

\service.py", line 83, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: ‘chromedriver‘ 

executable needs to be in PATH. Please see 

https://sites.google.com/a/chromium.org/chromedriver/home

然后我去下载chromedriver,随便下了一个版本的,结果又报错:

DevTools listening on ws://127.0.0.1:12059/devtools/browser/c21c107d-fa6a-

4739-8cd6-0f1718fb6db8
Traceback (most recent call last):
[38752:39792:0423/153855.462:ERROR:plugin_data_remover_impl.cc(123)] Timed 

out
  File "f5.py", line 6, in <module>
  File "D:\Anaconda3\lib\site-packages\selenium\webdriver\remote

\webdriver.py", line 726, in maximize_window
    self.execute(command, {"windowHandle": "current"})
  File "D:\Anaconda3\lib\site-packages\selenium\webdriver\remote

\webdriver.py", line 310, in execute
    response = self.command_executor.execute(driver_command, params)
  File "D:\Anaconda3\lib\site-packages\selenium\webdriver\remote

\remote_connection.py", line 466, in execute
    return self._request(command_info[0], url, body=data)
  File "D:\Anaconda3\lib\site-packages\selenium\webdriver\remote

\remote_connection.py", line 490, in _request
    resp = self._conn.getresponse()
  File "D:\Anaconda3\lib\http\client.py", line 1331, in getresponse
    response.begin()
  File "D:\Anaconda3\lib\http\client.py", line 297, in begin
    version, status, reason = self._read_status()
  File "D:\Anaconda3\lib\http\client.py", line 258, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "D:\Anaconda3\lib\socket.py", line 586, in readinto
    return self._sock.recv_into(b)
ConnectionResetError: [WinError 10054] 远程主机强迫关闭了一个现有的连接。

之后继续百度寻找答案,才发现:
再使用selenium打开chrome浏览器的时候,需要用chromedriver,而chromedriver与
chrome的版本也是要相互适宜的,对应关系如下:

chromedriver版本 支持的Chrome版本
v2.36 v64-66
v2.35 v62-64
v2.34 v61-63
v2.33 v60-62
v2.32 v59-61
v2.31 v58-60
v2.30 v58-60
v2.29 v56-58

所以,先在浏览器地址栏输入:chrome://version
得到浏览器的版本,之后找到对应的chromedriver版本,并下载。
下载链接是:

以上是关于selenium:chromedriver与chrome版本的对应关系的主要内容,如果未能解决你的问题,请参考以下文章

selenium:chromedriver与chrome版本的对应关系

selenium:chromedriver与chrome版本的对应关系

selenium chromedriver与chrome版本对照表

selenium chromedriver geckodriver iedriverserver下载

mac python selenium Chromedriver配置

selenium - chromedriver 可执行文件需要在 PATH [重复]