【发布时间】:2015-04-19 21:24:26
【问题描述】:
我将此代码 sn-p 作为 python 代码的一部分来抓取特定网站(请参见下面的代码)。但令我惊讶的是,输出代码不是 html。我正在使用 python 3.4
import urllib.request as ur
user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
headers = { 'User-Agent' : user_agent }
s = ur.urlopen('http://www.nairaland.com')
pl = s.read()
print(pl)
这段代码的输出是:
b''
而不是预期的 html 代码。请指导我使此代码正常工作。我需要代码的另一部分中的 html 代码。提前致谢。
【问题讨论】:
标签: python html web-crawler