Parsing an HTML a tag

Thorsten Kampe thorsten at thorstenkampe.de
Sun Sep 25 00:31:21 CEST 2005


* George (2005-09-24 18:13 +0100)
> How can I parse an HTML file and collect only that the A tags.

import formatter, \
       htmllib,   \
       urllib

url = 'http://python.org'

htmlp = htmllib.HTMLParser(formatter.NullFormatter())
htmlp.feed(urllib.urlopen(url).read())
htmlp.close()

print htmlp.anchorlist



More information about the Python-list mailing list