Reputation: 353
Trying to parse this html:
</thead>
<tbody>
<tr>
<td class="rank">
1.
</td>
<td class="name">
<a href="https://hoopshype.com/player/stephen-curry/salary/">
Stephen Curry </a>
</td>
<td style="color:black" class="hh-salaries-sorted" data-value="40231758">
$40,231,758 </td>
How do I pull "color:black" from here?
Upvotes: 0
Views: 30
Reputation: 11515
from bs4 import BeautifulSoup
data = """
</thead>
<tbody>
<tr>
<td class="rank">
1.
</td>
<td class="name">
<a href="https://hoopshype.com/player/stephen-curry/salary/">
Stephen Curry </a>
</td>
<td style="color:black" class="hh-salaries-sorted" data-value="40231758">
$40,231,758 </td>
"""
soup = BeautifulSoup(data, 'html.parser')
for item in soup.findAll('td', attrs={'class': 'hh-salaries-sorted'}):
print(item.get('style'))
Output:
color:black
Upvotes: 1