大家好…我想阅读http://www.nydailynews.com/上的“最受欢迎”专栏。在
Chrome中的代码如下所示:
所以我要:
url = "http://www.nydailynews.com/"
page = urllib2.urlopen(url)
soup = BeautifulSoup(page.read())
print soup.find_all(id = 'most-read-content')
但它什么也不返回。在
这里怎么了?是因为“最受欢迎”实际上是闪光灯还是什么?在
谢谢。在
Tags:
问题是从下载实际文本开始的。 按照您的代码,
page.read()
返回空结果页面的源代码的第一行包含
content="text/html; charset=utf-8"
,但这不是真的,或者代码没有设置为读取utf-8“问题是服务器返回由Gzip压缩的数据。”
参考如下:
encoding problem in Python when urlopen() a gbk page
相关问题 更多 >
编程相关推荐