python urllib2 html编码匹配

 

import urllib2
import re
url = 'http://192.168.80.128/'
charset_reg =r'<meta.*charset="?([\w|-]*)"?\s*/?>'
patten = re.compile(charset_reg)
req = urllib2.Request(url)
html = urllib2.urlopen(req).read()
code = patten.search(html).group(1)
print code
print html.decode(code)

  

 

正则表达式:  <meta.*charset="?([\w|-]*)"?\s*/?>html

 

作个笔记在这python

=====================================================正则表达式

seo:编码

 

网页编码正则表达式url

网页编码正则表达式spa

网页编码正则表达式code

相关文章
相关标签/搜索