自上一个以来的新帖子被标记为重复,对不起,情况并非如此。
我在使用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] 删除。
我来说两句