Python中过滤HTML标签的函数

时间:2022-07-25
本文章向大家介绍Python中过滤HTML标签的函数,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
#用正则简单过滤html的<>标签
import re
str = "<img /><a>srcd</a>hello</br><br/>"
str = re.sub(r'</?w+[^>]*>','',str)
print (str)
import re

test='<p>just for test</p><br/><font>just for test</font><b>test</b>'
pat = re.compile('(?<=>).*?(?=<)')
result=''.join(pat.findall(test))