def strip_tags ( html ):"""Python中过滤HTML标签的函数>>> str_text=strip_tags("<font color=red>hello</font>")>>> print str_texthello"""from HTMLParser import HTMLParserhtml = html . strip ()html = html . strip ( " \n " )result = []parser = HTMLParser ()parser . handle_data = result . appendparser . feed ( html )parser . close ()return '' . join ( result )
python 去除html标签函数
最新推荐文章于 2023-03-05 18:49:21 发布