【发布时间】:2011-04-27 13:13:30
【问题描述】:
我正在尝试使用 Python 下载网站的 HTML 源代码,但收到此错误。
Traceback (most recent call last):
File "C:\Users\Sergio.Tapia\Documents\NetBeansProjects\DICParser\src\WebDownload.py", line 3, in <module>
file = urllib.urlopen("http://www.python.org")
AttributeError: 'module' object has no attribute 'urlopen'
我在这里遵循指南:http://www.boddie.org.uk/python/HTML.html
import urllib
file = urllib.urlopen("http://www.python.org")
s = file.read()
f.close()
#I'm guessing this would output the html source code?
print(s)
我正在使用 Python 3。
【问题讨论】:
标签: python python-3.x urllib