python去除html标签

2015-06-04 0 839
python去除html标签

python去除html标签,自己写的,若有不足请指正:

#! /usr/bin/env python
#coding=utf-8
# blueel 2013-01-19
from HTMLParser import 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()

遇见资源网 python python去除html标签 http://www.ox520.com/15435.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务