Reputation: 9
How do I get the text of that bold element? Thanks in advance
<tr>
<td>
<div class="graph-legend-color"
style="width:12px;height:11px;background-
color:#3366CC">
</div>
</td>
<td class="percent">48,9 %</td>
<td class="number">92.234</td>
**<td>Proxy-Block Types From Download Media Type Blocklist</td>**
</tr>
Upvotes: 0
Views: 43
Reputation: 195553
As you see, the bold element (<td>
) is last <td>
element inside the <tr>
tag. So you select all <td>
tags inside <tr>
tag and get the element with index -1
(in Python that means last index):
data = """
<tr>
<td>
<div class="graph-legend-color"
style="width:12px;height:11px;background-
color:#3366CC">
</div>
</td>
<td class="percent">48,9 %</td>
<td class="number">92.234</td>
<td>Proxy-Block Types From Download Media Type Blocklist</td>
</tr>"""
from bs4 import BeautifulSoup
soup = BeautifulSoup(data, 'lxml')
print(soup.select('tr > td')[-1].text)
Prints:
Proxy-Block Types From Download Media Type Blocklist
Upvotes: 1