f = urllib2.urlopen(url,timeout=10)
data = f.read()   
# decode the html
contentType = f.headers.get('Content-Type')
if contentType.find("gbk"):
    data = unicode(data, "GBK").encode("utf-8")
elif contentType.find("utf-8"):
    pass

posted on 2015-04-30 17:38  何石-博客  阅读(573)  评论(0编辑  收藏  举报