-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
49eba96
commit 02ee520
Showing
1 changed file
with
20 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
Regex and Parsing/Detect HTML Tags, Attributes and Attribute Values/Solution.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from HTMLParser import HTMLParser | ||
|
||
class MyHTMLParser(HTMLParser): | ||
def handle_starttag(self, tag, attrs): | ||
print tag | ||
for attr, value in attrs: | ||
print "->", attr, ">", value | ||
|
||
def handle_startendtag(self, tag, attrs): | ||
print tag | ||
for attr, value in attrs: | ||
print "->", attr, ">", value | ||
|
||
html = '' | ||
for _ in range(int(raw_input())): | ||
html += raw_input().rstrip() + '\n' | ||
|
||
parser = MyHTMLParser() | ||
parser.feed(html) | ||
parser.close() |