Python ';连接中止。';,ConnectionResetError(104,';对等方重置连接';)
我在Google Colab中运行这个脚本Python ';连接中止。';,ConnectionResetError(104,';对等方重置连接';),python,python-requests-html,Python,Python Requests Html,我在Google Colab中运行这个脚本 import pandas as pd import requests from bs4 import BeautifulSoup as b url = "http://resultadoshistorico.onpe.gob.pe/EG2021/EleccionesPresidenciales/RePres/P/020000/021300" html = requests.get(url) content=html.conten
import pandas as pd
import requests
from bs4 import BeautifulSoup as b
url = "http://resultadoshistorico.onpe.gob.pe/EG2021/EleccionesPresidenciales/RePres/P/020000/021300"
html = requests.get(url)
content=html.content
soup=b(content,"lxml")
print(soup)
但我总是收到这个消息
---------------------------------------------------------------------------
ConnectionResetError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
599 body=body, headers=headers,
--> 600 chunked=chunked)
601
24 frames
ConnectionResetError: [Errno 104] Connection reset by peer
During handling of the above exception, another exception occurred:
ProtocolError Traceback (most recent call last)
ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
During handling of the above exception, another exception occurred:
ConnectionError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
496
497 except (ProtocolError, socket.error) as err:
--> 498 raise ConnectionError(err, request=request)
499
500 except MaxRetryError as e:
ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
我曾经尝试过从Mozilla迁移到Brave,以便再次尝试,但结果是一样的。
我还查看了Stackoverflow中的另一个讨论,但他们建议安装requests[security]
。我不确定Google Colab是否能做到这一点
希望有人能帮助我