【发布时间】:2021-12-31 00:00:20
【问题描述】:
所以我想简单地阅读网站的 Html 使用
from urllib.request import urlopen
url = 'https://dictionary.cambridge.org/dictionary/english/water'
page = urlopen(url)
对于某些网站,它可以正常工作,但对于上面代码中的某些网站,我得到了错误
Traceback (most recent call last):
File "F:/mohammad Desktop/work spaces/python/Python Turial Release 3.9.1/mod2.py", line 4, in <module>
page = urlopen(url)
File "C:\Python\Python38\lib\urllib\request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "C:\Python\Python38\lib\urllib\request.py", line 525, in open
response = self._open(req, data)
File "C:\Python\Python38\lib\urllib\request.py", line 542, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
File "C:\Python\Python38\lib\urllib\request.py", line 502, in _call_chain
result = func(*args)
File "C:\Python\Python38\lib\urllib\request.py", line 1362, in https_open
return self.do_open(http.client.HTTPSConnection, req,
File "C:\Python\Python38\lib\urllib\request.py", line 1323, in do_open
r = h.getresponse()
File "C:\Python\Python38\lib\http\client.py", line 1322, in getresponse
response.begin()
File "C:\Python\Python38\lib\http\client.py", line 303, in begin
version, status, reason = self._read_status()
File "C:\Python\Python38\lib\http\client.py", line 272, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response
有一些类似的问题,但没有对我有用的解决方案。
【问题讨论】:
标签: python python-3.x urlopen