2011-01-05 56 views

回答

1

那麼在這種情況下,你不需要解析任何東西,你只需要得到一個HTTP請求,並得到流,就像這樣:

HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://www.whatismyip.com/automation/n09230945.asp"); 
    using (StreamReader reader = new StreamReader(req.GetResponse().GetResponseStream())) 
    { 
     Console.WriteLine(reader.ReadToEnd()); 
    } 

如果你真的想使用Html Agility Pack,這是等效的:

HtmlWeb web = new HtmlWeb(); 
    Console.WriteLine(web.Load("http://www.whatismyip.com/automation/n09230945.asp").DocumentNode.OuterHtml);