0

I want to retrieve my Bitcoin mining hashrate from my pool webpage and store it as an int so that I can print it to the console. I tried using the HtmlAgilityPack which never seemed to have worked while using this code:

protected void Page_Load(object sender, EventArgs e) { string Url = "http://www.metacritic.com/game/pc/halo-spartan-assault"; HtmlWeb web = new HtmlWeb(); HtmlDocument doc = web.Load(Url); string metascore = doc.DocumentNode.SelectNodes("//*[@id=\"main\"]/div[3]/div/div[2]/div[1]/div[1]/div/div/div[2]/a/span[1]")[0].InnerText; string userscore = doc.DocumentNode.SelectNodes("//*[@id=\"main\"]/div[3]/div/div[2]/div[1]/div[2]/div[1]/div/div[2]/a/span[1]")[0].InnerText; string summary = doc.DocumentNode.SelectNodes("//*[@id=\"main\"]/div[3]/div/div[2]/div[2]/div[1]/ul/li/span[2]/span/span[1]")[0].InnerText; } 

From this Stack Exchange question. This ended up being confusing and I couldn't figure out how to make it return the desired value.

Is there any simpler or more intuitive way of getting this value?

2
  • AngleSharp is HTML parsing library that uses CSS selectors, maybe it will help with XPath hell here Commented Feb 28, 2016 at 16:52
  • Thanks for the suggestion I'll try it out. Commented Feb 28, 2016 at 16:59

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.