beautifulsoup: find_all sur bs4.de l'élément.Objet ResultSet ou de la liste?

Salut j'applique donc find_all sur un beautifulsoup object, et de trouver quelque chose, ce qui est un bs4.element.ResultSet object ou un list.

Je veux faire find_all là, mais il n'est pas permis sur un bs4.element.ResultSet object. Je peut faire une boucle sur chaque élément de la bs4.element.ResultSet object faire find_all. Mais peut-on éviter d'en boucle et juste reconvertir beautifulsoup object?

Voir le code pour plus de détails s'il vous plaît. Grâce

html_1 = """
<table>
    <thead>
        <tr class="myClass">
            <th>A</th>
            <th>B</th>
            <th>C</th>
            <th>D</th>
        </tr>
    </thead>
</table>
"""
soup = BeautifulSoup(html_1, 'html.parser')

type(soup) #bs4.BeautifulSoup

# do find_all on beautifulsoup object
th_all = soup.find_all('th')

# the result is of type bs4.element.ResultSet or similarly list
type(th_all) #bs4.element.ResultSet
type(th_all[0:1]) #list

# now I want to further do find_all
th_all.find_all(text='A') #not work

# can I avoid this need of loop?
for th in th_all:
    th.find_all(text='A') #works

OriginalL'auteur YJZ | 2016-03-18