Last active
December 31, 2015 11:08
-
-
Save mundry/7977281 to your computer and use it in GitHub Desktop.
List the tags used in a (set of) HTML file(s).
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
#!/usr/bin/env python2.7 | |
from sys import argv | |
from bs4 import BeautifulSoup | |
from bs4.element import Tag | |
soup = None | |
tags = set() | |
for html_file in argv[1:]: | |
with open(html_file) as fin: | |
soup = BeautifulSoup(fin.read()) | |
for child in soup.find('body').descendants: | |
if isinstance(child, Tag): | |
tags.add(child.name) | |
print '\n'.join(sorted(tags)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment