Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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)
 
PREVIOUS NEXT
Tagged: #processing #html #file #python
ADD COMMENT
Topic
Name
9+2 =