Reputation: 21274
I am trying to use BeautifulSoup for the first time to read a table.
print table_body
works but
rows = table_body.find_all('tr')
gives
TypeError: 'NoneType' object is not callable.
The result of the print table_body
is:
<tbody>
<tr>
<td>1</td>
<td><input type="checkbox" checked="checked" value="1098371296_GG14" class="tick_select" name="tick_select" id="tick_1098371296_GG14" /></td>
<td><a href="application.jsp?number=1322801&cycle=16/17&route=routecode&seq=0">1098371296</a></td>
<td>GG14</td>
<td>Joe</td>
<td>Doe</td>
<td>US</td>
<td>15/16</td>
<td>15/01/15</td>
<td></td>
<td>05/05/15</td>
<td></td>
<td>R</td>
<td> <abbr title="Withdrawn">Cw</abbr> <abbr title="MS">Mt</abbr> <abbr title="UF elsewhere">Ue</abbr></td>
<td></td>
</tr>
[...]
What am I doing wrong?
I am using BeautifulSoup version 3.2.1.
Upvotes: 0
Views: 126
Reputation: 473843
To add and to change the focus of the @larsr's answer:
You should not be using BeautifulSoup 3 - it is no longer maintained. Instead upgrade:
pip install --upgrade beautifulsoup4
And make sure you import it as:
from bs4 import BeautifulSoup
Upvotes: 2
Reputation: 5811
It is because findAll
is renamed find_all
in more recent versions of BeautifulSoup, so write table_body.findAll('tr')
instead.
Upvotes: 1