这个拓展很有用
本帖最后由 SuperBoy007 于 2017-9-12 22:02 编辑
问下为何审查元素看到的utf-8编码,用chardet模块看到的确实GB2312?
真是屌的不行!厉害厉害!
gaomengsuijia 发表于 2016-7-20 14:02
>>> file = rq.urlopen("http://www.sina.com")
>>> html = file.read()
>>> chardet.detect(html)
>>> import urllib.requestas rq
>>> file = rq.urlopen("http://www.sina.com")
>>> import chardet
>>> html = file.read()
>>> chardet.detect(html)['encoding']
'utf-8'
>>> chardet.detect(html)
我试了试,好好的
{'confidence': 0.99, 'encoding': 'utf-8', 'language': ''}
Python 3.2安装不了怎么办
小甲鱼赞!
发现了新大陆~
不错不错,终于学到这里了
chardet模块里没有detect这个函数啊= =
支持下 这个确实不错哦~
很难受,你们都有ez_setup.py文件么
给力
太给力了~~~
你的网站编码变了。对于新手锻炼不到,只不过看到了也非常好。
不错,request 要用r.content识别
r = requests.get(url)
if chardet.detect(r.content)["encoding"] == "GB2312":
r.encoding = "GBK"
else:
r.encoding = chardet.detect(r.content)["encoding"]
为什么我的fishc是这个??
{'encoding': 'Windows-1254', 'confidence': 0.4510049011289909, 'language': 'Turkish'}
厉害了
欸欸欸,可是我,用的是GB2312decode为什么没有报错……?!
学习了