I’ve been trying to nail down the correct select
string to obtain the Song Name, Artist Name, and Image from this radio station’s web page: https://mykgbi.com/recently-played/
From looking at the Firefox console, I know the elements I want are at the following CSS Selector / CSS Paths:
Song title:
CSS Selector: div.currentsonginfo:nth-child(2) > h4:nth-child(1) > span:nth-child(1) > a:nth-child(1)
CSS Path: html.js.flexbox.canvas.canvastext.webgl.no-touch.geolocation.postmessage.no-websqldatabase.indexeddb.hashchange.history.draganddrop.websockets.rgba.hsla.multiplebgs.backgroundsize.borderimage.borderradius.boxshadow.textshadow.opacity.cssanimations.csscolumns.cssgradients.no-cssreflections.csstransforms.csstransforms3d.csstransitions.fontface.generatedcontent.video.audio.localstorage.sessionstorage.webworkers.applicationcache.svg.inlinesvg.smil.svgclippaths body.archive.post-type-archive.post-type-archive-recentlyplayedsongs.tribe-js.tribe-theme-parent-nwm.tribe-theme-child-kgbi.fixed-nav div.wrapper div#streamer-container.default-stream section.streamer.inverse div.row.align-items-center div.col.col-auto.now_playing div.row.align-items-center.now_playing_content div.col.currentsonginfo h4 span.songname a.songlink
Artist name:
CSS Selector: div.currentsonginfo:nth-child(2) > p:nth-child(2) > span:nth-child(1) > a:nth-child(1)
CSS Path: html.js.flexbox.canvas.canvastext.webgl.no-touch.geolocation.postmessage.no-websqldatabase.indexeddb.hashchange.history.draganddrop.websockets.rgba.hsla.multiplebgs.backgroundsize.borderimage.borderradius.boxshadow.textshadow.opacity.cssanimations.csscolumns.cssgradients.no-cssreflections.csstransforms.csstransforms3d.csstransitions.fontface.generatedcontent.video.audio.localstorage.sessionstorage.webworkers.applicationcache.svg.inlinesvg.smil.svgclippaths body.archive.post-type-archive.post-type-archive-recentlyplayedsongs.tribe-js.tribe-theme-parent-nwm.tribe-theme-child-kgbi.fixed-nav div.wrapper div#streamer-container.default-stream section.streamer.inverse div.row.align-items-center div.col.col-auto.now_playing div.row.align-items-center.now_playing_content div.col.currentsonginfo p span.artistname a.artistlink
Image:
CSS Selector: div.now_playing:nth-child(1) > div:nth-child(2) > div:nth-child(1) > img:nth-child(1)
CSS Path: html.js.flexbox.canvas.canvastext.webgl.no-touch.geolocation.postmessage.no-websqldatabase.indexeddb.hashchange.history.draganddrop.websockets.rgba.hsla.multiplebgs.backgroundsize.borderimage.borderradius.boxshadow.textshadow.opacity.cssanimations.csscolumns.cssgradients.no-cssreflections.csstransforms.csstransforms3d.csstransitions.fontface.generatedcontent.video.audio.localstorage.sessionstorage.webworkers.applicationcache.svg.inlinesvg.smil.svgclippaths body.archive.post-type-archive.post-type-archive-recentlyplayedsongs.tribe-js.tribe-theme-parent-nwm.tribe-theme-child-kgbi.fixed-nav div.wrapper div#streamer-container.default-stream section.streamer.inverse div.row.align-items-center div.col.col-auto.now_playing div.row.align-items-center.now_playing_content div.col.col-auto.current_photo img
Realizing I might need three different sensors for this, I’m focusing on just the song title for now. Here’s my sensor attempt:
- platform: scrape
resource: https://mykgbi.com/recently-played/
# select: 'div.currentsonginfo:nth-child(2) > h4:nth-child(1) > span:nth-child(1) > a:nth-child(1)'
# select: "div.currentsonginfo:nth-child(2) > h4:nth-child(1) > span:nth-child(1) > a:nth-child(1)"
select: 'h4 > span > a'
name: KGBI RDS
The commented out lines are two of the many other combinations I’ve tried. I noticed the documentation and examples sometimes use ’ and sometimes ", so I’ve tried both with each string just in case that makes a difference. I restart the server every time to reinitiate the sensor. I’ve tried ".songlink"
which should retrieve class="songlink"
according to the Beautiful Soup CSS selector documentation. I’ve tried too many other combinations to document.
I have yet to retrieve any text, but sometimes the sensor is blank, sometimes it’s “Unknown,” and other times it’s a different color as if it were retrieving something, but there’s no text. From the examples which I also pasted in to be sure I could at least follow an example, I should be seeing some text when I look at the sensor here:
Can someone please help me figure out the correct select
values here?