gzip 压缩的网页解码 gbk
url = 'http://www.xxoo.com/'
req = urllib2.Request(url)
req.add_header('Accept-Encoding', 'gzip, deflate');
f = urllib2.urlopen(req, timeout=30)
html = f.read()
if html[:6] == '\x1f\x8b\x08\x00\x00\x00':
html = gzip.GzipFile(fileobj = cStringIO.StringIO(html)).read()
html.decode('gbk')
a = html.decode('gbk')
print a