8 class AnchorCollector(htmllib
.HTMLParser
):
9 def __init__(self
, *args
, **kw
):
11 htmllib
.HTMLParser
.__init
__(self
, *args
, **kw
)
13 def get_anchor_info(self
):
16 def anchor_bgn(self
, *args
):
17 self
.__anchors
.append(args
)
20 class HTMLParserTestCase(unittest
.TestCase
):
21 def test_anchor_collection(self
):
23 parser
= AnchorCollector(formatter
.NullFormatter(), verbose
=1)
25 """<a href='http://foo.org/' name='splat'> </a>
26 <a href='http://www.python.org/'> </a>
30 self
.assertEquals(parser
.get_anchor_info(),
31 [('http://foo.org/', 'splat', ''),
32 ('http://www.python.org/', '', ''),
38 test_support
.run_unittest(HTMLParserTestCase
)
41 if __name__
== "__main__":