|
下面这段代码取到的数据怎么都是乱码呢?在同一网站的另一页面(https://www.okcoin.com/api/ticker.do?symbol=ltc_cny),读取的数据又是正常的!请各位大哥大姐帮忙看看!!
string html = "";
string txtUri = "https://www.okcoin.com/api/depth.do?symbol=ltc_cny";
HttpWebRequest req = WebRequest.Create(txtUri) as HttpWebRequest;
HttpWebResponse res = req.GetResponse() as HttpWebResponse;
Stream s = res.GetResponseStream();
if (res.StatusCode == HttpStatusCode.OK)
{
using (s) //using表示回收使用的内存
{
using (StreamReader sr = new StreamReader(s, Encoding.GetEncoding("gb2312"))) //UTF-8 Unicode defaule这些全都试过了
{
html = sr.ReadToEnd();
sr.Close();
}
s.Close();
}
}
|
|