views:

24

answers:

1

Ok so I can reference my table correctly in a html page like this:

form = soup.findAll('form')[1]

table = form.findAll('table', width="79%")  # returns 1 table, doing a print shows table with rows

tr = table.findAll('tr')

I get an error:

ResultSet object has no attribute findAll.

Why doesn't this work? I used the output of form.findAll to get the table, and the table (using print) does indeed have table rows etc.

+3  A: 

As in the previous question, findAll returns a list.

So,

table = form.findAll('table', width='79%')[0]
tr = table.findAll(...)

will extract the first one. As before, check that your list isn't empty first.

ars
But I did a len(table) and it was 1? I guess I still ahve to do [0] ok I get it.
Blankman
Right, len(table) just gives you the length. Once you know it's > 0, then extract the element with the index ([0] gets the first one).
ars
check my history, I am accepting all the time now.
Blankman
@Blankman: cool. :)
ars