首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

采集网页 返回信息不全,该怎么解决

2012-09-12 
采集网页 返回信息不全C# codestring url http://technet.microsoft.com/zh-cn/security/bulletin/MS11

采集网页 返回信息不全

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; 


试试

热点排行