[問題]HtmlAgilityPack抓取氣象資料問題
各位大大好,爬了很久了文不知道問題出在哪,在想可能是GOOGLE的方向錯誤,想直接上
來問問大家,在此先謝謝各位了。
我利用HtmlAgilityPack,想去撈氣象局的資料,但是在foreach node的地方卻一直出現
NullReferenceException未處理,好像是沒有讀到指定的node,但是PATH又是正確的
同樣的方法,去抓IMDB的資料就可以成功的取得,不知道問題出在哪?
以下是部分程式碼
WebClient client = new WebClient();
string temp = "";
using (MemoryStream ms = new MemoryStream
(client.DownloadData("http://www.cwb.gov.tw/m/f/town368/1001013.php")))
{
HtmlAgilityPack.HtmlDocument doc = new
HtmlAgilityPack.HtmlDocument();
doc.Load(ms, Encoding.UTF8);
// 取得所有符合條件的nodes
HtmlNodeCollection nodes =
doc.DocumentNode.SelectNodes("//div[@id='gt']//span[@class='degree blue']");
foreach (HtmlNode node in nodes)
{
temp = node.InnerText;
}
/
textBox1.Text = temp;
}
麻煩各位了QAQ
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 111.242.254.155
※ 文章網址: https://www.ptt.cc/bbs/C_Sharp/M.1439380967.A.F06.html
→
08/12 21:02, , 1F
08/12 21:02, 1F
→
08/12 21:02, , 2F
08/12 21:02, 2F
謝謝iterator大回覆!! 請問有辦法利用 C# 抓取動態生成的資料嗎?
您所給的ftp資料只有天氣預報,沒有"現在"天氣狀況QQ 還是謝謝非常您~~~
→
08/12 22:12, , 3F
08/12 22:12, 3F
謝謝unstoppable大,請問要怎麼修改呢QQ,他到了動態生成的部分就會找不到了QQ
※ 編輯: dastania (111.242.254.155), 08/12/2015 23:43:03
→
08/12 23:51, , 4F
08/12 23:51, 4F
→
08/13 00:09, , 5F
08/13 00:09, 5F
→
08/13 02:42, , 6F
08/13 02:42, 6F
→
08/13 02:43, , 7F
08/13 02:43, 7F
→
08/13 03:43, , 8F
08/13 03:43, 8F
推
08/14 03:10, , 9F
08/14 03:10, 9F