Reputation: 4924
I read other threads related to my issue but it did not solve the problem.
<h2 class="tabellen_ueberschrift al">Cards</h2>
<div class="fl" style="width:49%;">
<table class="tabelle_grafik lh" cellpadding="2" cellspacing="1">
<tr>
<th class="al" colspan="3">CA Osasuna</th>
</tr>
<td class="s10 al">
<a href="/en/sisi/profil/spieler_51713.html" class="fb s10" title="Sisi">Sisi</a>
<br />
26. min. 2. yellow card, Time wasting </td>
</tr>
I want to get all the a
tags (there will be several) within the table so my code is this:
header = soup.find('h2', text="Cards")
cards_table = header.find_next_siblings(limit=2)
for row in cards_table.find_all('a'):
print row
This raises me
AttributeError: 'ResultSet' object has no attribute 'find_all'
cards_table
is a table and I iterate over it with the for
loop so not sure why this is causing the error. Ideas please?
Upvotes: 2
Views: 6937
Reputation: 4924
Ok, the code was missing one line:
for line in cards_table:
for row in line.find_all('a'):
print row
cards_table
is a list so we had to iterate over it before we could use the find_all
method for the table.
Upvotes: 6