I am web-scraping with Python
and using BeutifulSoup
library
I have HTML
markup like this:
<tr class="deals" data-url="www.example2.com">
<span class="hotel-name">
<a href="www.example2.com"></a>
</span>
</tr>
<tr class="deals" data-url="www.example3.com">
<span class="hotel-name">
<a href="www.example3.com"></a>
</span>
</tr>
I want to get the data-url
or the href
value in all <tr>
s. Better If I can get href
value
Here is a little snippet of my relevant code:
main_url = "http://localhost/test.htm"
page = requests.get(main_url).text
soup_expatistan = BeautifulSoup(page)
print (soup_expatistan.select("tr.deals").data-url)
# or print (soup_expatistan.select("tr.deals").["data-url"])