Answers for "how to do processing on html file using python"

1

how to do processing on html file using python

from html.parser import HTMLParser
class MyHTMLParser(HTMLParser):
    def handle_comment(self,data):
        print("Encountered comment:- ",data)
        pos = self.getpos()
        print("At line ",pos[0],"and position",pos[1])
        
parser = MyHTMLParser()
html_file = open("simple.html")
if html_file.mode == "r":
    contents = html_file.read()
    parser.feed(contents)
Posted by: Guest on October-06-2021

Code answers related to "how to do processing on html file using python"

Python Answers by Framework

Browse Popular Code Answers by Language