我正在嘗試使用 Python 下載網站的 HTML 源代碼,但收到此錯誤。
Traceback(最近一次調用最後一次):文件“C:UsersSergio.TapiaDocumentsNetBeansProjectsDICParsersrcWebDownload.py”,第 3 行,在 <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() #我猜這會輸出html源代碼? print(s)
我正在使用 Python 3。