-2

I want to take the "total member" number (on the right bar of the website) and display that number inside a label in C# windows form application. Here is the website: https://www.dojrp.com/ Thanks

JLW1808
  • 106
  • 9
  • it says that the 3 word "[HtmlDocument]" is not valid in the given context. – JLW1808 Jan 03 '19 at 02:06
  • Of course, that is meant to be your `webBrowser1.Document`. Also, the number is inside a `SPAN`, not a `DIV` (my bad), so the actual code would be: `HtmlElement element = webBrowser1.Document.GetElementsByTagName("SPAN").OfType().FirstOrDefault(elm => elm.GetAttribute("className").Equals("ipsDataItem_stats_number"));`. The number is then in `string Number = element.InnerHtml;`. Remember to set `webBrowser1.ScriptErrorsSuppressed = true;`, that's a dynamic page. – Jimi Jan 03 '19 at 02:10

1 Answers1

2

Here is a solution to solve your problem:

Step 1. Get the html code of this website page using System.Net.WebClient class.

Step 2. Locate the "total member" number in the html code and get it using System.Text.RegularExpressions.Regex class.

Step 3. Assign that number to your label on your windows form.

Ousmane D.
  • 54,915
  • 8
  • 91
  • 126
ojlovecd
  • 4,812
  • 1
  • 20
  • 22
  • Trolling newcomers with Regex… like it!!! (whoever reads the answer - please make your life easier and use HTML parsers - https://stackoverflow.com/questions/56107/what-is-the-best-way-to-parse-html-in-c is much better guidance and following is good read about [html and regex](https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/)). – Alexei Levenkov Jan 03 '19 at 02:16