0

As an example, I want to get the sub count for youtube music from socialblade. I was able to download the page with string rawWeb = webStream.DownloadString("https://socialblade.com/youtube/channel/UC-9-kyTW8ZkZNDHQJ6FgpwQ/realtime")

But I couldn't understand how to separate the text I want (Line:295<p id="rawCount" style="display: none;">98199073</p>) from the rest of the code, and from there how to single out the number only

I got Regular expressions would be the best way to do this but I can't wrap my head around the format. Nothing seemed to work. If you can help, it would be greatly appreciated :)

*Using .NET 4.5.2

Soiah
  • 11
  • 2

1 Answers1

0

Regex is the wrong approach to this, you are far better off using the HTML agility Pack (Install with Nuget)

http://html-agility-pack.net/

then use C#

var url = "https://socialblade.com/youtube/channel/UC-9-kyTW8ZkZNDHQJ6FgpwQ/realtime";
var web = new HtmlWeb();
var doc = web.Load(url);

var n = doc.DocumentNode.Descendants().FirstOrDefault(d => d.Id == "rawCount")?.InnerText;
Console.WriteLine(n);

VB

Dim url = "https://socialblade.com/youtube/channel/UC-9-kyTW8ZkZNDHQJ6FgpwQ/realtime"
Dim web = New HtmlWeb()
Dim doc = web.Load(url)

Dim n = doc.DocumentNode.Descendants().FirstOrDefault(Function(d) d.Id = "rawCount").InnerText

Console.WriteLine(n)

enter image description here

Keith Nicholas
  • 43,549
  • 15
  • 93
  • 156