标签:blog os ar div art on c log html
class MyParser(HTMLParser): def __init__(self,key): self.data=[] self.key=key self.falg=False self.linkname=‘‘ HTMLParser.__init__(self) def handle_starttag(self,tag,attrs): if self.key and tag ==self.key: self.falg=True def handle_data(self,data): if self.falg and data: self.data.append(unicode(eval(repr(data)),"utf-8")) def handle_endtag(self,tag): if self.key and tag ==self.key: self.falg=False def getresult(self): return self.data def get_html_tagdata(data,tag): IParser = MyParser(tag) IParser.feed(data) result=IParser.getresult() IParser.close() return result
标签:blog os ar div art on c log html
原文地址:http://www.cnblogs.com/huangjianan/p/3998139.html