https://gist.github.com/anonymous/f7781da21b44925a36320e61b6f27283
print h.text # 乱码
我范例是从露天拍卖抓资料可是出现都是乱码, 后来google 有人提到露天网页编码是 big5
后来我找到有人针对露天拍卖编码去转成unicode
http://bugcaptor.logdown.com/posts/181043-the-big5-page-requests-get-back-into-python-utf8
b = h.text.encode('latin-1').decode('big5')
UnicodeDecodeError: 'big5' codec can't decode bytes in position 207-208:
illegal multibyte sequence
但会出现上面错误讯息
后来我改成utf-8 网页资料就正常
b = h.text.encode('latin-1').decode('utf-8')
好奇露天拍路编码是 big5 那为什么用 latin-1 转成 str 在用decode('utf-8') 转回 unicode
这样会是正确?
print h.encoding 想去看编码可是看到编码是 ISO-8859-1 怎么跟big5 utf8 latin-1 都没关系?
谢谢