为何不能完整读取网页数据
WebClient MyWebClient = new WebClient();
string html = MyWebClient.DownloadString("http://bbs.dahe.cn/bbs/thread-1647174-2498-1.html");
为何 读出来的数据 不完整啊?(读出的只有大概 不到64K 的数据)你可直接打开网页,查看源文件,可看出数据量不一样
------------------------------
当然,若网页数据量不大时,读取是没问题的
大家碰到过这种情况吗?如何解决?谢谢啦!
[解决办法]
WebClient MyWebClient = new WebClient();MyWebClient.Headers[HttpRequestHeader.AcceptEncoding] = "gzip, deflate";string html = MyWebClient.DownloadString("http://bbs.dahe.cn/bbs/thread-1647174-2498-1.html");
[解决办法]
压缩的可使用
System.IO.Compression.DeflateStream responseStream =new System.IO.Compression.DeflateStream( httpWebResponse.GetResponseStream(),System.IO.Compression.CompressionMode.Decompress);