我正在遵循《用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
有关可能是什么原因的任何线索?
谢谢。