string ip= SendRequest("http://pv.sohu.com/cityjson?ie=utf-8");
// <summary>
/// Get方式获取url地址输出内容
/// </summary> /// <param name="url">url</param>
/// <param name="encoding">返回内容编码方式,例如:Encoding.UTF8</param>
public static string SendRequest(string url)
{
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.Method = "GET";
HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();
StreamReader sr = new StreamReader(webResponse.GetResponseStream(), Encoding.UTF8);
return sr.ReadToEnd();
}
08-25
07-07
1865
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)