2
我使用python urllib2.urlopen获取html内容,我得到一个gziped响应。
我可以设置标题,所以我会得到它不拉链?我如何设置一个标题,防止网站发送gzip编码响应
我的代码
response = urlopen(url,None , TIMEOUT)
html = response.read() # read html
print html
为Tichodroma建议我试试这个
request = Request(url)
request.add_header('Accept-encoding', 'text/plain')
response = urlopen(request,None , TIMEOUT)
html = response.read().lower() # read html
print html
现在它正在
http://stackoverflow.com/questions/3947120/dose-python-urllib2-will-automaticly-uncompress-gzip-data-from-fetch完全重复 - 网页 – 2012-02-02 11:47:26
没有它不是重复 - 我不想解压缩它我想要得到它不在第一个位置 – yossi 2012-02-02 12:37:25