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

相关文章:

  • 2021-11-27
  • 2021-12-07
  • 2022-12-23
  • 2022-02-09
  • 2018-05-07
  • 2022-03-05
  • 2021-11-30
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-11
相关资源
相似解决方案