简体   繁体   中英

Scrape InnerText from body of website C#

I'm trying to gather the data from this website: http://services.runescape.com/m=hiscore_oldschool/index_lite.ws?player=f2pshrympy

using HtmlAgilityPack;
using System;

var webGet = new HtmlWeb();
var document = webGet.Load("http://services.runescape.com/m=hiscore_oldschool/index_lite.ws?player=f2pshrympy");
var bodyText = document.DocumentNode.SelectNodes("/html/body/text()");
Console.WriteLine(bodyText);
Console.ReadLine();

When the program is run nothing is printed to the console and there are no errors.

screenshot of the console

I'm guessing that nothing is being found with the XPath "/html/body/text()", any ideas how I can go around fixing this?

Your page is pure text. So you don't need any tool like HtmlAgilityPack to parse it. Just download it and use it.

using (var wc = new WebClient())
{
    var bodyText = wc.DownloadString("http://services.runescape.com/m=hiscore_oldschool/index_lite.ws?player=f2pshrympy");

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM