发布时间:2019-09-22 07:59:02编辑:auto阅读(2448)
def pick_charset(html):
"""
从文本中提取 meta charset
:param html:
:return:
"""
charset = None
m = re.compile('<meta .*(http-equiv="?Content-Type"?.*)?charset="?([a-zA-Z0-9_-]+)"?', re.I).search(html)
if m and m.lastindex == 2:
charset = m.group(2).lower()
return charset
注意引入 re,如果有更好的方法欢迎联系 coconets@163.com
上一篇: Python “编辑距离”(Levens
下一篇: Python 发出警报声音 简单播放声音
51028
50416
41025
37888
32358
29251
28133
22970
22931
21259
1133°
1839°
1486°
1422°
1708°
1513°
2172°
3750°
3672°
2587°