[英]Can't get the target table by XPath through HTMLAgility Pack in C#
我想从“ WindGuru”站点获取数据。
在通过chrome's
内置功能复制目标表的XPath
之后。
它一次又一次抛出NullReferenceException
...
请告诉我如何解决这个问题。
谢谢你们。 :)
这是我的代码片段...
WebClient client = new WebClient();
MemoryStream ms = new MemoryStream(client.DownloadData("http://www.windguru.cz/int/index.php?sc=572782"));
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.Load(ms, Encoding.ASCII);
HtmlAgilityPack.HtmlDocument docWindContext = new HtmlAgilityPack.HtmlDocument();
docWindContext.LoadHtml(doc.DocumentNode.SelectSingleNode(@"//*[@id='div_wgfcst1']/table").InnerHtml);
您的ID后没有任何表格。 我想您正在尝试查找包含所有数据的json部分?
尝试以下方法:
docWindContext.LoadHtml(doc.DocumentNode.SelectSingleNode(@"//*[@id='div_wgfcst1']/script").InnerHtml);
(将表更改为脚本)然后您将获得我想得到的所有js代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.