from urllib.request import urlopen import io from lxml import etree #1/27/2012 my first python script works!! Recursed tree of my homepage and printed all tags. def printTree(): u = io.TextIOWrapper(urlopen("http://www.fallenhobbit.com"), encoding='latin1') text = u.read() parser = etree.HTMLParser() tree = etree.fromstring(text, parser) print(tree.tag) treecont = tree.getchildren() for chld in treecont: printChildren(chld) def printChildren(node): print(node.tag) for chld in node: printChildren(chld) def main(): printTree() if __name__ == "__main__": main()