Good Morning / Afternoon
I would be grateful for your help to give further clarity and direction using Beautiful Soup. My end goal if to have three variables
- artist
- song
- station
I can currently extract the artist and song together (concatenated) and the radio station. This is in the format {str} \n\n artist song\n track hit \n
The code I have used below returns 20 tags which I can then use to extract the information above. My question to you all is - how can I retrieve the text from the raw code below using <div class = "table__track-title" <div class = "table__track-on air"
these would be combined with <tr class = "now-playing-tr" which was used initially to retrieve the result set of 20 records.
Code used to obtain the HTML subset import bs4,requests,re
siteurl = 'https://onlineradiobox.com/uk/?cs=uk'
r = requests.get(siteurl)
soup = bs4.BeautifulSoup(r.text,'html.parser')
x = soup.find_all(class_='now_playing_tr')
for i in range(len(x)):
currtext = x[i].get_text()
HTML <button aria-label="Listen live" class="b-play station_play" radioid="uk.cheekyhits"
radioimg="//cdn.onlineradiobox.com/img/l/2/88872.v2.png" radioname="Cheeky Hits"
stream="https://stream.zeno.fm/ys9fvbebgwzuv"
streamtype="mp3" title="Listen to radio"></button>
<img alt="Billy Joel - The DownEaster Alexa" src="https://is2-
ssl.mzstatic.com/image/thumb/Music124/v4/bf/b7/db/bfb7dbd8-6d55-d42a-a0f0-
3ecc5681cf9c/20UMGIM12176.rgb.jpg/30x30bb.jpg"><div class="table__track-title"><b>Billy
Joel</b> The DownEaster Alexa</div>
<div class="table__track-onair">Cheeky Hits</div>
</img></td></tr>