[Tutor] Newbie question - syntax - BeautifulSoup

Tommy Kaas tommy.kaas at kaasogmulvad.dk
Wed Jul 28 22:58:59 CEST 2010

-----Oprindelig meddelelse-----
Fra: tutor-bounces+tommy.kaas=kaasogmulvad.dk at python.org
[mailto:tutor-bounces+tommy.kaas=kaasogmulvad.dk at python.org] På vegne af
Alan Gauld
Sendt: 28. juli 2010 20:00
Til: tutor at python.org
Emne: Re: [Tutor] Newbie question - syntax - BeautifulSoup

"Tommy Kaas" <tommy.kaas at kaasogmulvad.dk> wrote

> for row in soup('table', {'class' : 'spad'})[0].tbody('tr'):
> The example works fine, and I can change it a bit and it still 
> works. But I
> simply don't understand how I am supposed to the fourth line - after 
> "for
> row in soup". I can clearly see it defines the area I want to 
> scrape, but
> how is the syntax build?

Do you understand the syntax from a Python point of view?

No. That's the problem.

> that information myself? I have tried to read the help-file of
> BeautifulSoup, but found nothing there.

Which help file?

Well, maybe not a file, but the text produced by typing: help(BeautifulSoup)

There is a fairly good tutorial for Beautiful Soup here:


Is that the one you meant?

Did you find the section "Searching By CSS class"?

If so we need more specific questionws about what you don't 
If not, try reading it and then come back for more... :-)


Alan Gauld
Author of the Learn to Program web site

Tutor maillist  -  Tutor at python.org
To unsubscribe or change subscription options:

More information about the Tutor mailing list