python - Python webdriver远程触发[WinError 10061]无连接
问题描述
Python webdriver.Remote突然触发“WinError 10061 No connection...”错误
嗨,我有一个 python 脚本,它使用 selenium 从网络上抓取一些数据。它已经运行了几个月没有任何问题。当脚本崩溃时,我偶尔会做的一件事是使用 webdriver.Remote 基本上继续在之前打开的浏览器上工作。曾经工作的简单代码行在下面共享:
chrome = webdriver.Remote(command_executor=command_executor_val, desired_capabilities={})
变量“command_executor_val”基本上是一个包含值“ http://127.0.0.1:53463 ”的字符串。大约一周后,这行代码触发了错误信息:
Traceback (most recent call last):
chrome = webdriver.Remote(desired_capabilities=DesiredCapabilities().CHROME, command_executor=command_executor_val)
File "C:\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 154, in __init__
self.start_session(desired_capabilities, browser_profile)
File "C:\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 243, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 310, in execute
response = self.command_executor.execute(driver_command, params)
File "C:\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 466, in execute
return self._request(command_info[0], url, body=data)
File "C:\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 528, in _request
resp = opener.open(request, timeout=self._timeout)
File "C:\Python\Python36-32\lib\urllib\request.py", line 526, in open
response = self._open(req, data)
File "C:\Python\Python36-32\lib\urllib\request.py", line 544, in _open
'_open', req)
File "C:\Python\Python36-32\lib\urllib\request.py", line 504, in _call_chain
result = func(*args)
File "C:\Python\Python36-32\lib\urllib\request.py", line 1346, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "C:\Python\Python36-32\lib\urllib\request.py", line 1320, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [WinError 10061] No connection could be made because the target machine actively refused it>
我真的不知道为什么会这样。我阅读了Selenium 远程 webdriver 错误(连接被拒绝)和使用 HTTP 代理 - Python和Python urllib.request.urlopen() 返回错误 10061?但它们似乎都不是由 webdriver.Remote 触发的。
我不记得在我的机器上安装过任何东西。我有 Windows 和 Chrome 作为默认浏览器。在此先感谢您的任何建议。
解决方案
推荐阅读
- java - java应用程序中连接到外部服务器的问题
- javascript - 如何导出一个里面有函数的函数?
- javascript - 将电子 NativeImage 从
.capturePage() 到 base64 或 dataURL - php - 为什么 PhpStorm 将 Laravel 控制器方法识别为未使用?
- delphi - DEVMODE 结构没有彩色打印能力打印机的颜色属性
- c# - 将 .Net Core 中的多个复杂对象从视图传递到控制器
- excel - 添加基本形状左/右箭头作为可点击的上一个/下一个按钮
- selenium - 错误向网格注册的请求不成功:404
- java - 如何让我的处理程序在微秒而不是毫秒内调用可运行对象?
- javascript - 从旋转向量中获取 Yaw、Pitch、Roll