Scrape Sensor - Get attribute

Currently, it’s impossible to get the value of an attribute in a tag using the scraper, because it only grabs the content of the selected tag, and then strips all tags contained in it.

This would be especially useful, for example when scraping a podcast feed, to grab the URL of the podcast audio/video file.

Using the BeautifulSoup library directly, I was able to get the url of the podcast from this feed: http://wsrss.bbc.co.uk/bizdev/bbcminute/bbcminute.rss
Using this code:
print(data.select('enclosure:nth-of-type(1)')[0]['url'])

Ended up doing it myself. It was super simple. PR*2 incoming.

Done: https://github.com/home-assistant/home-assistant/pull/10001 & https://github.com/home-assistant/home-assistant.github.io/pull/3696

1 Like

Edit:
Nevermind, it works with multiple attributes.


Is it possible to make this work for multiple attributes under one tag?

Or am I just not understanding how to do it correctly?

<meta property="og:description" content="Base solution for your next web application">