嗨所以我在a上应用find_all beautifulsoup object,并找到一些东西,这是一个bs4.element.ResultSet object或一个list.
我想在那里进一步做find_all,但是不允许这样做 bs4.element.ResultSet object.我可以循环遍历bs4.element.ResultSet objectfind_all的每个元素.但是我可以避免循环并将其转换回来beautifulsoup object吗?
请参阅代码了解详情.谢谢
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 …Run Code Online (Sandbox Code Playgroud)