on-internet
← Community

Parsing with Python html.parser: accessing and using raw tags

Stack Overflow ·

I'm not a Python specialist, so bear with me. I'm trying to replace a Perl HTML::TokeParser based parser that I use for template foreign language translation to use Python html.parser. Here's the prototype code which nearly gives me what I want. import deepl from html.parser import HTMLParser class MyHTMLParser(HTMLParser): def handle_starttag(self, tag, attrs): result = '<' + tag + '>' print('start ' + str(result)) for attr in attrs: print(" attr:", attr) def handle_endtag(self, tag): result = '</' + tag + '>' print('end ' + str(result)) #print("End tag :", tag) def handle_data(self, data): s

Comments

Sign in or sign up to comment and upvote.

No comments yet.