Python中的以下代码通常会给我url变量中指定的网站的html。 Urlopen工作正常。问题是:从现在开始使用特定网站,我无法使此代码正常工作。
from urllib.request import urlopen
url = "http://www.somewebsite.com"
html = urlopen(url)
print(html.read())
错误如下:
File "C:/script.py", line 4, in <module>
html = urlopen(url)
[...]
File "C:\Python\Python35\lib\http\client.py", line 251, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response