c# 搜狐 腾讯 都是这样。。。新浪可以
我试了一下,继检查,是搜狐的内容经过了GZIP压缩,报以才出现你这样的问题。具体解决方法如下:
System.Net.WebClient wc = new System.Net.WebClient();
wc.BaseAddress = "http://www.sohu.com";
//注意,new GZipStream。。。这一句是解决问题的重点,需要引用命名空间 System.IO.Compression;
using (System.IO.Stream objStream = new GZipStream(wc.OpenRead("/"), CompressionMode.Decompress))
{
using (System.IO.StreamReader _read = new System.IO.StreamReader(objStream, System.Text.Encoding.Default))
{
Response.Write(_read.ReadToEnd());
}
}
OK,问题成功解决