Kent Johnson writes: > [EMAIL PROTECTED] wrote: >> anchor.findNext('code') fails: >> >> anchor = soup.fetch('a', {'href': '/wiki/List_of_country_calling_codes'}) >> print anchor >> >> [<a href="/wiki/List_of_country_calling_codes" title="List of country >> calling codes">Calling code</a>] >> >> anchor.findNext('code') >> [] > > are you sure that's what you got? Looks like an AttributeError to me - > anchor is a *list* of anchors. Try > anchor[0].findNext('code') > > Kent >
With 'fetch' you get a list of Tag objects, so there is that using: anchor = soup.fetch('a', {'href': '/wiki/List_of_country_calling_codes'}) anchor[0].findNext('code') But with 'findChild' or 'first' you get only the first Tag that matches, so: anchor = soup.findChild('a', {'href': '/wiki/List_of_country_calling_codes'}) anchor.findNext('code') Thanks for your help, Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor