webclinet downstring 搜狐 为什么是个?号
生活随笔
收集整理的這篇文章主要介紹了
webclinet downstring 搜狐 为什么是个?号
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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,問題成功解決
總結
以上是生活随笔為你收集整理的webclinet downstring 搜狐 为什么是个?号的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 医疗卫生信息化 医学信息 医院管理 医疗
- 下一篇: linux之管道