日期:2014-05-18 浏览次数:20381 次
public string ReadUrlContent(string rUrl) { // used to build entire input StringBuilder sb = new StringBuilder(); // 请求该页面 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(rUrl); // 获取返回的数据(通过相应) HttpWebResponse response = (HttpWebResponse)request.GetResponse(); //将读取到的数据放入到流里面 Encoding enc = Encoding.GetEncoding("GB2312"); //如果是乱码就改成 utf-8 / GB2312 StreamReader loResponseStream = new StreamReader(response.GetResponseStream(), enc); sb.Append(loResponseStream.ReadToEnd()); loResponseStream.Close(); return sb.ToString(); }