<td class="generic_td_class" data-test="specific-location">
<span class="generic-span-class">Text I want to extract</span>
</td>
I am trying to extract the span text from a few locations using Python and Beautifulsoup. I am able to successfully get the span contents using the class, but I need to get multiple values from different areas of the webpage, and the only unique aspect I can search by is the data-test="specific-location" inside of the td (which are all unique). How would I go about doing this?
I've tried this:
soup.find('td', data-test_="specific-location").text.strip()
But I get the following error:
SyntaxError: keyword can't be an expression
Any assistance would be greatly appreciated.