Skip to content

Commit

Permalink
Regex and Parsing!
Browse files Browse the repository at this point in the history
  • Loading branch information
snehalmastud authored Feb 23, 2020
1 parent ac2391c commit 56a3074
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Regex and Parsing/HTML Parser- Part 1/Solution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from __future__ import print_function
import sys
if sys.version_info[0]>=3:
raw_input=input
from html.parser import HTMLParser
else:
from HTMLParser import HTMLParser

from HTMLParser import HTMLParser
class MyHTMLParser(HTMLParser):
def handle_starttag(self, tag, attrs):
print("Start : "+tag)
for e in attrs: print("-> "+e[0]+" > "+str(e[1]))
def handle_endtag(self, tag):
print("End : "+tag)
def handle_startendtag(self, tag, attrs):
print("Empty : "+tag)
for e in attrs: print("-> "+e[0]+" > "+str(e[1]))

parser = MyHTMLParser()
for _ in range(int(raw_input())):
parser.feed(raw_input())

0 comments on commit 56a3074

Please sign in to comment.