gzip解压压缩的字符串数据
2015-08-07 02:01
471 查看
import urllib2 from StringIO import StringIO import gzip def loadData(url): request = urllib2.Request(url) request.add_header('Accept-encoding', 'gzip') response = urllib2.urlopen(request) if response.info().get('Content-Encoding') == 'gzip': print 'gzip enabled' buf = StringIO(response.read()) f = gzip.GzipFile(fileobj=buf) data = f.read() else: data = response.read() return data
相关文章推荐
- lvm扩展记录
- StringIO模块字符串的缓存
- egret调用页面js的方法。
- StringIO模块字符串的缓存
- Cannot run gnome extension in browser
- UltraEdit 除去行首的行号和空格
- Python转码问题的解决方法:ignore,replace,xmlcharrefreplace
- Unity Manual之ScriptableObject 脚本化对象
- Python转码问题的解决方法:ignore,replace,xmlcharrefreplace
- setuptools,easy_install使用
- setuptools,easy_install使用
- C 语言中的变量为什么不能以数字打头
- C 语言中的变量为什么不能以数字打头
- python:利用asyncio进行快速抓取
- python:利用asyncio进行快速抓取
- os.path.exists(path) 和 os.path.lexists(path) 的区别
- os.path.exists(path) 和 os.path.lexists(path) 的区别
- isdigit()判断是不是数字
- isdigit()判断是不是数字
- mongoDb的索引