[英]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.