当前位置:编程学习 > python >>

Python过滤HTML标签的函数源码

Python过滤HTML标签的函数
#用正则简单过滤html的<>标签


import re

str = "<img /><a href=http://www.zzzyk.com>站长资源库</a>hello</br><br/>"
str = re.sub(r'</?\w+[^>]*>','',str)
print (str)


Python过滤HTML代码的源码

import re

test='<p>just for test</p><br/><font>just yizuotu.net test</font><b>易做图</b>'
pat = re.compile('(?<=\>).*?(?=\<)')
result=''.join(pat.findall(test))
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,