`
gChenDev
  • 浏览: 28203 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

python抓网页中文乱码问题

阅读更多

import urllib2
import sys
content = urllib2.urlopen("http://www.higis.cn").read()   #网站页面是utf-8编码的。

type = sys.getfilesystemencoding()   # 关键
print content.decode("UTF-8").encode(type)  # 关键
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics