python中清除html标签,pythonhtml标签,如下代码实现清除html
python中清除html标签,pythonhtml标签,如下代码实现清除html
如下代码实现清除html标签功能,需要引用HTMLParser包。
class MLStripper(HTMLParser): def __init__(self): self.reset() self.fed = [] def handle_data(self, d): self.fed.append(d) def get_data(self): return ''.join(self.fed)def strip_tags(html): s = MLStripper() s.feed(html) return s.get_data()
使用strip_tags()函数就可以把string中的html标签去掉!
相关内容
- python手动释放 内存的问题, python explicitly free memory.,
- python使用unittest进行单元测试,pythonunittest,simptest.py#
- python时间和时间戳之间的相互转换,python时间相互转换
- python filter使用示例,pythonfilter示例,列表用得比较多,
- python使用ConfigParser库读取配置文件,pythonconfigparser,温习
- python 检测关键词在百度的排名,python关键词,python检测
- python urllib 使用总结,pythonurllib,import urlli
- python使用sgmllib库 SGMLParser解析页面中的链接地址,sgm
- python使用ftplib做ftp操作,pythonftplib,ftplib是 Pyth
- webpy的LightTPD配置,webpyLightTPD配置,在生产环境下推荐在
评论关闭