[Tutor] problems with HTMLParser

Sean 'Shaleh' Perry shaleh@valinux.com
Wed, 24 Jan 2001 15:20:53 -0800 (PST)


On 24-Jan-2001 Danny Yoo wrote:
> On Tue, 23 Jan 2001, Sean 'Shaleh' Perry wrote:
> 
>> gah, HTMLParser should not be this hard.  Also, when I get this working 
>> eventually I want the text wrapped in the anchor too, how do i get that?
> 
> Hmmm... let's take another look.  From the last version of your source:
> 
> 
> So there's a definition for start_a(), but there needs to be a definition
> of end_a(); they act as a pair.  That's probably why it's complaining:
> 
>>   File "/usr/lib/python1.5/sgmllib.py", line 336, in handle_endtag
>>     method()  # seems to die on end_a?
>> TypeError: not enough arguments; expected 2, got 1
> 
> Add a do-nothing end_a() method to your class, and with luck, that should
> fix that bug.
> 

you are right, another look at the source was needed, but your analysis was off
(-:

Problem was my declaration of my end_foo() functions:

def end_li(self, attributes)

there are no attributes of end tags, doh.  Removing the extra option made
everything happy.

The error message is because the end_ function I defined had two parameters and
the one it was expecting only took self.