日期:2014-05-17  浏览次数:21070 次

采集网页 返回信息不全
C# code

            string url = "http://technet.microsoft.com/zh-cn/security/bulletin/MS11-086";
            HtmlAgilityPack.HtmlWeb webClient = new HtmlAgilityPack.HtmlWeb();
            HtmlAgilityPack.HtmlDocument doc = webClient.Load(url);               



将doc.DocumentNode.InnerHtml 显式在窗口的textbox里,只显示到“</strong> 1.0</p> <div “为止,后面就没有了,
但如果单步调试,doc.DocumentNode.InnerHtml的值又是正确的,
3c 64 69 76 20 78 6d 6c 6e 73 3d 22 68 74 74 70 <div xml ns="http 这里并没有特殊字符。

单步调试的时候程序可以正确运行,但是真要运行的时候,网页的结构却又无法解析,这是为什么呢?

------解决方案--------------------
public string getfiles(string urls) 

WebRequest wrq; 
HttpWebResponse wrp; 

wrq=HttpWebRequest.Create(urls); 
wrp=(HttpWebResponse)wrq.GetResponse(); 
Stream resStream=wrp.GetResponseStream(); 
StreamReader sr = new StreamReader(resStream, System.Text.Encoding.Default); 
string tempstr = sr.ReadToEnd(); 
return tempstr; 


试试