HtmlAgilityPack 是否能够以字符串的形式从 HtmlDocument 对象返回 完整 HTML 标记?
You can create WebRequest passing Url and Get webResponse . Get ResponseStream from WebResponse and read it into a String.
string result = string.Empty; WebRequest req = WebRequest.Create(Url); WebResponse res= wrq.GetResponse(); StreamReader reader = new StreamReader(res.GetResponseStream()); result = reader.ReadToEnd(); reader.Close(); res.Close();
Hope this helps.
Sure, you can do like this:
HtmlDocument doc = new HtmlDocument(); // call one of the doc.LoadXXX() functions Console.WriteLine(doc.DocumentNode.OuterHtml);
OuterHtml contains the whole html.