html 2 txt (完善中)

import re

filename=raw_input('input a filename,please  ')
s=file(filename).read()
ss=s.replace('\n','')
ss=ss.replace(' ','')
ss=ss.replace('»','')
ss=re.sub("<!--.+?-->",' ',ss)
tem=re.sub("<.*?>",'',ss)
w=open('zip.txt','w')
w.write(tem)
w.close()

你可能感兴趣的:(html)