|
楼主 |
发表于 2016-5-5 19:19:30
|
显示全部楼层
public string HttpGet_ziLiao(string url, string postData)
{
//post参数
Encoding encode = Encoding.GetEncoding("utf-8");//网页编码==Encoding.UTF8
byte[] bt = encode.GetBytes(postData);
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(new Uri(url));
req.Method = "POST";
req.CookieContainer = CookieContainers;
req.ContentType = "application/x-www-form-urlencoded";
req.Accept = "text/html,text/css,application/xhtml+xml, */*";
req.Connection = "Keep - alive";
Stream streamReq = req.GetRequestStream();
streamReq.Write(bt, 0, bt.Length);
streamReq.Close();
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
Stream streamRes = res.GetResponseStream();
StreamReader reader = new StreamReader(streamRes, encode);
string result = reader.ReadToEnd();
return result;
} |
|