B-Soup: broken iterator, tag a keyword?

Brendan brendandetracey at yahoo.com
Thu Jul 10 08:05:49 EDT 2008


Hi there,
I have the following using Beautiful Soup:

soup = BeautifulSoup(data)
tags = soup.findAll(href=re.compile("/MER_FRS_L2_Canada/MER_FRS_\S
+gz"))
for tag in tags:
    print tag['href']
    print tag.parent.nextSibling.string
    print tag.parent.nextSibling.nextSibling.string
    print tag.parent.nextSibling.nextSibling.nextSibling.string
    print
tag.parent.nextSibling.nextSibling.nextSibling.nextSibling.contents[0].string


For some reason I do not understand, using 'tag' as an iterator breaks
the code. Can someone tell me why? reading dir(soup) did not
illuminate me.

Thanks



More information about the Python-list mailing list