Urllib3-Selenium ConnectionResetError-WinError 10054-初始化webdriver.Chrome

自上一个以来的新帖子被标记为重复,对不起,情况并非如此。

我在使用urllib3和Seleninum时遇到了一些困难。

由于某种原因,我的一个硒脚本(其他都不错)在打开webdriver.Chrome时一开始就崩溃了。

该错误似乎是“随机”的。它不会工作几个小时,然后可以正常工作。

我不了解的是,如果在此阶段仅初始化浏览器远程主机如何关闭连接

根据日志,这是失败的地方:

chrome_webdriver = 'G:/Selenium/chromedriver_win32/chromedriver.exe'
chrome_options = Options()
chrome_options.add_argument("--allow-insecure-localhost")
chrome_options.add_argument("--ignore-certificate-errors")
chrome_options.add_argument("log-level=3")
chrome_options.add_argument("--start-maximized")
try:
   logging.info("Starting webdriver")   
   browser = webdriver.Chrome(
        options=chrome_options,
        executable_path=chrome_webdriver)
   logging.info("Webdriver launched")   
except Exception as e:
   logging.error(repr(e))
   exit

netstat -b在主机上运行,但是刚得到时,我看不到端口正在使用或处于TIME_WAIT状态:

INFO -- Starting webdriver
ERROR -- ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))

完整的错误是否可以帮助您:

Traceback (most recent call last):
  File "E:\Python3\lib\site-packages\urllib3\connectionpool.py", line 672, in urlopen
    chunked=chunked,
  File "E:\Python3\lib\site-packages\urllib3\connectionpool.py", line 421, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "E:\Python3\lib\site-packages\urllib3\connectionpool.py", line 416, in _make_request
    httplib_response = conn.getresponse()
  File "E:\Python3\lib\http\client.py", line 1336, in getresponse
    response.begin()
  File "E:\Python3\lib\http\client.py", line 306, in begin
    version, status, reason = self._read_status()
  File "E:\Python3\lib\http\client.py", line 267, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "E:\Python3\lib\socket.py", line 589, in readinto
    return self._sock.recv_into(b)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

任何帮助,我们将不胜感激,不胜感激。

信息

ChromeDriver 79.0.3945.36(最新)

Chrome版本为79.0.3945.130版(最新)

防火墙已禁用

urllib3版本:1.25.8

python版本:3.7.4

我不知道为什么,但是将硒从Chrome切换到Firefox可以完成工作,脚本可以按预期工作。

我仍然不明白为什么会有这个错误-Winerror 100054-仅适用于Chrome,但如果有人遇到此问题,至少它可以正常工作

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Python 3和Windows 7:ConnectionResetError:[WinError 10054]远程主机强行关闭了现有连接

Python3 Selenium Webdriver 在初始化期间超时

API 教程中的 WinError 10054

使用 Selenium webdriver.Chrome 导致 PermissionError: [WinError 5] Access is denied

MySQL 服务器已消失 ConnectionResetError 10054 Flask SqlAlchemy

Selenium和Heroku:urllib3.exceptions.ProtocolError:('连接异常终止。',ConnectionResetError(104,'对等重置连接'))

selenium ConnectionRefusedError:[WinError 10061]在python 3中

Chrome Webdriver Selenium内存错误-Python 3

Python-尝试使用Selenium登录网站时出现urllib3 MaxRetryError

使用python-Requests / urllib3 /或selenium模块获取多个Web URL的状态代码

初始化Selenium WebDriver时如何解决python-Selenium错误“连接被拒绝”?

Selenium FirefoxDriver初始化

Selenium Webdriver c#:获取“路径不是合法形式。” 在初始化FirefoxProfile时

<urlopen 错误 [WinError 10054] 远程主机强行关闭了现有连接>

FileNotFoundError WinError 3

python Selenium PermissionError:[WinError 5]访问被拒绝

带有Selenium的Python Chromedriver WinError 2

右键单击某个元素时,出现“未初始化的常量 Selenium::WebDriver::DriverExtensions::HasInputDevices (NameError)”错误

通过Selenium Webdriver管理Chrome策略

Selenium::WebDriver::Firefox 和 Chrome 出错

使用Headless Chrome Webdriver运行Selenium

如何获取XPath for Selenium Webdriver for Chrome

Selenium网格到远程Webdriver(chrome)挂起

在Python + Selenium Chrome WebDriver中处理通知

无法从Selenium Webdriver启动IE / Chrome

chrome 84 webdriver 与 selenium 3.141.0 兼容吗?

使用 Javascript 和 Selenium Webdriver (Chrome) 登录

如何访问 cookie (Capybara/Selenium Chrome Webdriver)

从 chrome 85 开始的零星 Selenium Chrome WebDriver 超时