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