need help with python syntax

Mike Meyer mwm at
Sun Dec 25 00:29:51 EST 2005

homepricemaps at writes:
> if i have a piece of html that looks like this
> <tr class="rulesbody">
> <td width="183" class="rulesbody">
> and i want to scrape out , what syntax would i use?  i have
> tried this and it doesn't work
> for incident in bs('td', {'class' : 'rulesbody'}, {'class' :
> 'rulesbody'} ):

If you're using BeautifulSoup, you don't need to pass in the second
dictionary. For that matter, you don't need to pass in the first one -
bs.fetch (which is what calling a tag object calls) will treat a
bare string as a request for a class. On the other hand, I don't like
using the callable objecdt shortcut, and prefer spelling out fetch
explicitly. So you'd write:

for incident in bs.fetch('td', 'rulesbody'):


Mike Meyer <mwm at>
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.

More information about the Python-list mailing list