In Python3.6 (selenium module): ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine

别来无恙 提交于 2020-01-25 00:13:05

问题


I am studying Python with the book "Automate the boring stuff with Python" (written by Al Sweigart) and I have a problem with web scraping (Chapter 11), namely the selenium module. I am writing the following in Python IDLE:

>>> from selenium import webdriver
>>> browser = webdriver.Firefox() # Here Windows command black window appears
                                  # and Mozilla Firefox with blank page opens
>>> browser.get('http://inventwithpython.com')
    Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    browser.get('http://inventwithpython.com')
  File "C:\Users\forwa\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 326, in get
    self.execute(Command.GET, {'url': url})
  File "C:\Users\forwa\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 312, in execute
    response = self.command_executor.execute(driver_command, params)
  File "C:\Users\forwa\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 472, in execute
    return self._request(command_info[0], url, body=data)
  File "C:\Users\forwa\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 495, in _request
    self._conn.request(method, parsed_url.path, body, headers)
  File "C:\Users\forwa\AppData\Local\Programs\Python\Python36-32\lib\http\client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "C:\Users\forwa\AppData\Local\Programs\Python\Python36-32\lib\http\client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "C:\Users\forwa\AppData\Local\Programs\Python\Python36-32\lib\http\client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "C:\Users\forwa\AppData\Local\Programs\Python\Python36-32\lib\http\client.py", line 1065, in _send_output
    self.send(chunk)
  File "C:\Users\forwa\AppData\Local\Programs\Python\Python36-32\lib\http\client.py", line 986, in send
    self.sock.sendall(data)
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine

>>> browser.get('http://inventwithpython.com')

When I write >>> browser.get('http://inventwithpython.com') the first time, the error occurs. When I write this command the second time, the Mozilla Firefox browser opens desired web page. When I write the command the third time, the ConnectionAbortedError again occurs, and so on - the odd times of writing the command (1, 3, ...) result in the ConnectionAbortedError, and the even times (2, 4, ...) pass without error. I tried to turn off antivirus and firewall but it did not help. Please help me with the issue. P.S. I have Windows 10 OS.


回答1:


I'm the author of Automate the Boring Stuff with Python. I encountered this error as well on a Windows 10 machine. According to this StackOverflow answer https://stackoverflow.com/a/51005821/1893164 this seems to be a problem with geckodriver 0.21.0.

The workaround which worked for me was to install the older version of geckodriver, 0.20.1, which you can download here: https://github.com/mozilla/geckodriver/releases/tag/v0.20.1



来源:https://stackoverflow.com/questions/51160562/in-python3-6-selenium-module-connectionabortederror-winerror-10053-an-esta

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!