使用Python进行网页爬取:解析错误时出现意外的EOF

时间:2018-09-26 15:09:47

标签: python web-scraping eoferror

我正在遵循《用Python进行网络爬取》一书中的练习,但是在运行以下代码时遇到“解析时出现意外的EOF”错误:

from urllib.request import urlopen
from urllib.error import HTTPError
try:
    html = urlopen('http://www.pythonscraping.com/pages/page1.html')
except HTTPError as e:
    print(e)
    # return null, break, or do some other "Plan B"
else:
    # program continues. Note: If you return or break in the
    # exception catch, you do not need to use the "else" statement

有关可能是什么原因的任何线索?

谢谢。

0 个答案:

没有答案