Selenium ConnectionRefusedError:Python中非常稀疏的[WinError 10061]

时间:2019-04-10 11:08:52

标签: python python-3.x selenium

错误很少出现。硒就是这样。

循环:单击按钮> time.sleep(0.5)

我使用3 cmd运行相同的代码,但运行8小时后仅出现1个错误。

另外2个可以正常运行12个小时以上。

上周我每天工作12个小时,今天已经发生了3次。

如果站点阻止了我的IP地址,则其他2个cmd应该会吐出相同的错误。

出什么问题了?

Traceback (most recent call last):
  File "C:\Python\Python37\lib\site-packages\urllib3\connection.py", line 159, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw)
  File "C:\Python\Python37\lib\site-packages\urllib3\util\connection.py", line 80, in create_connection
    raise err
  File "C:\Python\Python37\lib\site-packages\urllib3\util\connection.py", line 70, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "C:\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 354, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "C:\Python\Python37\lib\http\client.py", line 1229, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "C:\Python\Python37\lib\http\client.py", line 1275, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "C:\Python\Python37\lib\http\client.py", line 1224, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "C:\Python\Python37\lib\http\client.py", line 1016, in _send_output
    self.send(msg)
  File "C:\Python\Python37\lib\http\client.py", line 956, in send
    self.connect()
  File "C:\Python\Python37\lib\site-packages\urllib3\connection.py", line 181, in connect
    conn = self._new_conn()
  File "C:\Python\Python37\lib\site-packages\urllib3\connection.py", line 168, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x034CE7D0>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test.py", line 690, in <module>

  File "test.py", line 102, in main
    set_button()
  File "test.py", line 248, in set_theater
    """
  File "C:\Python\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 688, in close
    self.execute(Command.CLOSE)
  File "C:\Python\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 319, in execute
    response = self.command_executor.execute(driver_command, params)
  File "C:\Python\Python37\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 374, in execute
    return self._request(command_info[0], url, body=data)
  File "C:\Python\Python37\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 397, in _request
    resp = self._conn.request(method, url, body=body, headers=headers)
  File "C:\Python\Python37\lib\site-packages\urllib3\request.py", line 68, in request
    **urlopen_kw)
  File "C:\Python\Python37\lib\site-packages\urllib3\request.py", line 89, in request_encode_url
    return self.urlopen(method, url, **extra_kw)
  File "C:\Python\Python37\lib\site-packages\urllib3\poolmanager.py", line 323, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "C:\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 667, in urlopen
    **response_kw)
  File "C:\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 667, in urlopen
    **response_kw)
  File "C:\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 667, in urlopen
    **response_kw)
  File "C:\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "C:\Python\Python37\lib\site-packages\urllib3\util\retry.py", line 398, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=1289): Max retries exceeded with url: /session/d0dcdddad707a4745765bc5ea12e4b52/window (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x034CE7D0>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it'))

0 个答案:

没有答案