BeautifulSoup,'ResultSet'对象没有属性'find_all'

nut*_*hip 2 beautifulsoup findall python-2.7

我读了与我的问题相关的其他线程,但它没有解决问题.

<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>
Run Code Online (Sandbox Code Playgroud)

我想得到表中的所有a标签(会有几个)所以我的代码是这样的:

header = soup.find('h2', text="Cards")
cards_table = header.find_next_siblings(limit=2)
for row in cards_table.find_all('a'):
    print row
Run Code Online (Sandbox Code Playgroud)

这引起了我的兴趣

AttributeError: 'ResultSet' object has no attribute 'find_all'
Run Code Online (Sandbox Code Playgroud)

cards_table是一个表,我用循环迭代它,for所以不知道为什么这会导致错误.想法好吗?

nut*_*hip 6

好的,代码缺少一行:

for line in cards_table:
    for row in line.find_all('a'):
        print row
Run Code Online (Sandbox Code Playgroud)

cards_table是一个列表,所以我们必须迭代它,然后才能使用该find_all方法.