从网络电台获取艺术家和标题 [英] Fetch artist and title from net radio

查看:54
本文介绍了从网络电台获取艺术家和标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi,
I am trying to fetch the artist and title from a website streaming live music.



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




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

推荐答案

< a href =https://html-agility-pack.net/> Html Agility pack |了解如何使用HtmlAgilityPack和教程&示例 [ ^ ]

可能对你有帮助。

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是歌曲名称。

这个例子是在C#中,但你可以很容易地重写它VB Net。


"node.InnerHtml" is the song name.
This example is in C# but you could easily rewrite it in VB Net.


这篇关于从网络电台获取艺术家和标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆