def finish_endtag(self, tag): SGMLParser.finish_endtag(self, tag) self.now_tag_attrs = {} # 一直pop,直到踢出与当前endtag匹配的为止。 # 这种现象是由于出现<meta/>这种只有starttag的标签导致的 while True: if cmp(tag, self.tag_stack[-1]) == 0: self.tag_stack.pop() break else: self.tag_stack.pop()