getting a KeyError:'href' any ideas?

homepricemaps at gmail.com homepricemaps at gmail.com
Tue Jan 24 14:40:14 EST 2006


ok the syntax for next is this:

b = n.findNext



LordLaraby wrote:
> You wrote:
> > i have an
> > href which looks like this:
> > <td class="all">
> >     <a class="btn" name="D1" href="http://www.cnn.com">
> >         </a>
> > here is my code
> > for incident in row('td', {'class':'all'}):
> >                 n = incident.findNextSibling('a', {'class': 'btn'})
> >                 link = incident.findNextSibling['href'] + "','"
> > any idea what i'm doing wrong here with the syntax?  thanks in advance
> Since you already found the anchor tag with the 'btn' class attribute,
> just grab it's href attribute like so:
> for incident in row('td', {'class':'all'}):
>        n = incident.findNextSibling('a', {'class': 'btn'})
>        link = n['href'] + "','"
> 
> Works for me...
> 
> LL




More information about the Python-list mailing list