Post navigation ← Previous Next → 网络抓取后转utf-8格式 Posted on 2015 年 7 月 18 日 by 张 子萌 要抓取的网页是gb2312的编码,但是脚本是在Linux下运行,使用utf-8,需要转码。 后来直接用转python的打印方法转换 import urllib _str = urllib.urlopen(“http://www.xxxxx.com”).read() get_data = u”%s” % _str.decode(‘gb2312’, ‘ignore’) get_data就是utf-8格式。 分享到: QQ空间 新浪微博 腾讯微博 人人网 更多
发表评论