从网站 C# 的正文中抓取 InnerText
Scrape InnerText from body of website C#
我正在尝试从该网站收集数据: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();
当程序 运行 没有任何内容打印到控制台并且没有错误。
screenshot of the console
我猜 XPath“/html/body/text()”没有找到任何东西,我有什么办法解决这个问题吗?
您的页面是纯文本。所以你不需要像 HtmlAgilityPack 这样的工具来解析它。只需下载并使用即可。
using (var wc = new WebClient())
{
var bodyText = wc.DownloadString("http://services.runescape.com/m=hiscore_oldschool/index_lite.ws?player=f2pshrympy");
}
我正在尝试从该网站收集数据: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();
当程序 运行 没有任何内容打印到控制台并且没有错误。
screenshot of the console
我猜 XPath“/html/body/text()”没有找到任何东西,我有什么办法解决这个问题吗?
您的页面是纯文本。所以你不需要像 HtmlAgilityPack 这样的工具来解析它。只需下载并使用即可。
using (var wc = new WebClient())
{
var bodyText = wc.DownloadString("http://services.runescape.com/m=hiscore_oldschool/index_lite.ws?player=f2pshrympy");
}