Merhaba, find_all öğesini beautifulsoup object
numaralı telefondan uygularım ve bir bs4.element.ResultSet object
veya list
olan bir şey buluyorum.beautifulsoup: find_all on bs4.element.ResultSet nesnesi veya listesi?
Daha fazla bilgiyi buradan öğrenmek istiyorum, ancak bs4.element.ResultSet object
numaralı telefona izin verilmiyor. Find_all yapmak için bs4.element.ResultSet object
öğesinin her bir öğesiyle döngü yapabilirim. Ama döngüden kaçınıp sadece beautifulsoup object
'a dönebilir miyim?
Lütfen ayrıntılar için kod bölümüne bakın. Teşekkür
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
th_all için soup.find_all sonucunu kopyaladıktan sonra, içinde yansıtmak th_all değişiklik yapmadan edecek çorba? –
Evet öyle olacak. Hangi işlevi kullandığınıza bağlı olarak değişir. Başvuru: https://beautiful-soup-4.readthedocs.io/en/latest/#modifying-the-tree –