HttpWebRequest request = (HttpWebRequest)WebRequest.Create(postUrl);
request.CookieContainer =
new
CookieContainer();
CookieContainer cookie = request.CookieContainer;
request.Referer =
""
;
request.Accept =
"Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
;
request.Headers[
"Accept-Language"
] =
"zh-CN,zh;q=0."
;
request.Headers[
"Accept-Charset"
] =
"GBK,utf-8;q=0.7,*;q=0.3"
;
request.UserAgent =
"User-Agent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1"
;
request.KeepAlive =
true
;
request.ContentType =
"application/x-www-form-urlencoded"
;
Encoding encoding = Encoding.UTF8;
request.Method =
"get"
;
string
postDataStr;
Stream requestStream = request.GetRequestStream();
if
(postDatas !=
""
)
{
postDataStr=postDatas;
byte
[] postData = encoding.GetBytes(postDataStr);
request.ContentLength = postData.Length;
requestStream.Write(postData, 0, postData.Length);
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader streamReader =
new
StreamReader(responseStream, encoding);
string
retString = streamReader.ReadToEnd();
streamReader.Close();
responseStream.Close();
return
retString;
|