import os import re import codecs from chardet universaldetector impor

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
import os
import re
import codecs
from chardet.universaldetector import UniversalDetector
findmeta = re.compile("^<meta.* charset *= *")
for line in file(fullname, 'rb'):
if findmeta.search(line):
newcharset = re.sub("^<meta.* charset *= *","",line)
newcharset = re.sub('" *.*$','',newcharset)