2012-01-14 132 views

回答

6

有2種方式取決於你想顯示信息的方式方法..

要麼你可以使用WebControl顯示在控制網站本身,

但我認爲你正在尋找解壓或網站從網頁報廢的數據,那麼你可以嘗試使用HtmlAgilityPack來解析HTML,並從那裏

一個示例代碼提取所需的信息:

string tickerid = "Bse_Prc_tick"; 
HtmlAgilityPack.HtmlDocument doc = new HtmlWeb().Load(@"http://www.moneycontrol.com/india/stockpricequote/computers-software/infosys-technologies/IT", "GET"); 

if(doc != null) 
{ 
    // Fetch the stock price from the Web page 
    string stockprice = doc.DocumentNode.SelectSingleNode(string.Format(".//*[@id='{0}']",tickerid)).InnerText; 
    Console.WriteLine(stockprice); 
} 

輸出:

2585.55 
+1

+1正確的答案,對於包括Codeplex上的鏈接 – 2012-01-14 22:04:39

+0

@GarryVass爲給予好評感謝名單... :) – 2012-01-16 06:17:30

+0

非常感謝謝卡爾:) :) :) – Shrikey 2012-01-16 13:35:04

相關問題