python 10053_在Python3.6(selenium模块)中:ConnectionAbortedError:[WinError 10053]已建立的连接被主机中的软件中止...

我正在学习Python,上面写着“使用Python自动化无聊的东西”(由Al Sweigart编写),我遇到了网络抓取问题(第11章),即selenium模块。我在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 "", line 1, in

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')

当我>>> browser.get('http://inventwithpython.com')第一次写时,会发生错误。当我第二次编写此命令时,Mozilla Firefox浏览器会打开所需的网页。当我第三次写命令时,会再次出现ConnectionAbortedError,依此类推 - 编写命令(1,3,...)的奇数次会导致ConnectionAbortedError,偶数次(2,4,... 。)传递没有错误。我试图关闭防病毒和防火墙,但它没有帮助。请帮我解决这个问题。PS我有Windows 10操作系统。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值