使用urlopen进行刮擦不适用于特定服务器

时间:2015-11-12 17:47:22

标签: python web-scraping urllib urlopen

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

0 个答案:

没有答案