解析GZIP压缩的网页
class Program { static void Main(string[] args) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://wthrcdn.etouch.cn/weather_mini?city=%E9%83%91%E5%B7%9E"); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream ResStream = new System.IO.Compression.GZipStream(response.GetResponseStream(), System.IO.Compression.CompressionMode.Decompress); Encoding encoding = Encoding.GetEncoding("utf-8"); StreamReader streamReader = new StreamReader(ResStream, encoding); string s = streamReader.ReadToEnd(); Console.WriteLine(s); Console.ReadKey(); } }
喜欢的朋友请帮忙点个赞!!!