Python Webdriver远程触发[WinError 10061]无连接

时间:2019-01-18 02:09:58

标签: python selenium

Python webdriver。远程突然触发“ WinError 10061 No connection ...”错误

嗨,我有一个Python脚本,该脚本使用Selenium从Web上抓取一些数据。它已经运行了几个月没有任何问题。脚本崩溃时,我偶尔要做的一件事是使用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 remote webdriver error (Connection refused)Using an HTTP PROXY - PythonPython urllib.request.urlopen() returning error 10061?,但似乎没有一个由webdriver.Remote触发。

我不记得在计算机上安装了任何东西。我有Windows和Chrome作为默认浏览器。预先感谢您的任何建议。

0 个答案:

没有答案