Click here to Skip to main content
15,121,818 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am trying to fetch the artist and title from a website streaming live music.

http://radioglobus.dk/netradio/?autoplay=true%22

If I hit F12 (Developer Tools) in Edge I can see the artist in <span class="nowPlayingArtist"></span><br />
And the title in <span class="nowPlayingTitle"></span><br />

But the above function returns everything except the artist and the title.

What do I need to fetch the artist and title?

Thank in advance


What I have tried:

Public Async Function GetIt(ByVal uri As String) As Task(Of String)
    Dim Content As String = Await wvRadio.InvokeScriptAsync("eval", New String() {"document.documentElement.outerHTML;"})
    Await Task.Delay(2000)
    If Content.Contains("playingnow") Then
        Debug.WriteLine(Content)
    End If
    Return ""
End Function
Posted
Updated 21-Nov-18 23:57pm

1 solution

Html Agility pack | Learn how to use HtmlAgilityPack with tutorial & example[^]
might help you.
var url = "http://radioglobus.dk/netradio/?autoplay=true%22";
var web = new HtmlWeb();
var doc = web.Load(url);
var nodes = doc.DocumentNode.SelectNodes("//span");
var node = nodes.FirstOrDefault(x => x.Attributes.Any(a => a.Name == "class" && a.Value == "nowPlayingTitle"));
if (node != null)
{
    Console.WriteLine(node.InnerHtml);
}

"node.InnerHtml" is the song name.
This example is in C# but you could easily rewrite it in VB Net.
   
Comments
N. Henrik Lauridsen 22-Nov-18 7:41am
   
Thank you very much for your reply. Unfortunately it returns nothing. Do you have an idea why the node is empty?
TheRealSteveJudge 22-Nov-18 11:32am
   
The debugger shows after loading the web page that the two spans are empty.
span class="nowPlayingArtist"></span
span class="nowPlayingTitle"></span
Maybe something more must happen that these two fields are actually filled.
A real web browser seems to behave differently in contrast to just downloading
the web page.
Sorry for any inconvenience.
N. Henrik Lauridsen 22-Nov-18 11:56am
   
It’s quite all right. Maybe a delay would help. Anyway, I have got to know about Html Agility Pack thanks to you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900