Reputation: 5968
html
<span class="percentage" data-qa="score1">
95%
</span>
<span class="percentage" data-qa="score2">
77%
</span>
code:
soup.find('span', class_='percentage')
Desire Result:
77%
Actual Results:
95%
Question
How do you specify the score2 value?
Upvotes: 0
Views: 144
Reputation: 782488
Use the attrs
argument to specify attributes in a dictionary.
soup.find('span', attrs={"class": "percentage", "data-qa": "score2"})
See How to use hyphen inside .find_all of BeautifulSoup?
Upvotes: 1