[Tutor] Newbie question - syntax - BeautifulSoup

Alan Gauld alan.gauld at btinternet.com
Wed Jul 28 19:59:37 CEST 2010


"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?

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

Which help file?
There is a fairly good tutorial for Beautiful Soup here:

http://www.crummy.com/software/BeautifulSoup/documentation.html

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 
understand.
If not, try reading it and then come back for more... :-)

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




More information about the Tutor mailing list