|
private string PostForm(string url, string user, string pwd, string code)
{
CookieContainer cookieer = new CookieContainer();
// str = GetCookie("http://www.juxiangyou.com/login/index");
string str= strSP(GetCookie("http://www.juxiangyou.com"));
string jxy_parameter = "%7B%22c%22%3A%22index%22%2C%22fun%22%3A%22login%22%2C%22account%22%3A%2213417191783%22%2C%22password%22%3A%22854312min%22%2C%22verificat_code%22%3A%22"+code+"%22%2C%22is_auto%22%3Afalse%7D×tamp=1515328170529";
// string jxy_parameter = "{'c':'index','fun':'login','account':'"+ user + "','password':'" + pwd + "','verificat_code':'" + code + "','is_auto':false}×tamp=1515328170529";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
//request.Method = "POST";
request.Method = "POST";
// request.CookieContainer = cookieer;
request.Headers.Add("Origin", "http://www.juxiangyou.com");
request.Referer = "http://www.juxiangyou.com/login/index";
request.Headers.Add("Accept-Language", "zh-Hans-CN,zh-Hans;q=0.5");
request.UserAgent = " Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299";
request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
request.Accept = "application/json, text/javascript, */*; q=0.01";
request.Headers.Add("X-Requested-With", "XMLHttpRequest");
request.Headers.Add("Accept-Encoding", "gzip, deflate");
request.Host = "www.juxiangyou.com";
//X-Sign: jc4r9nhd
request.Headers.Add("X-Sign", "jc4r9nhd");
request.Headers.Add("Pragma", "no-cache");
request.Headers.Add("Cookie", str);
Stream myRequestStream = request.GetRequestStream();
StreamWriter myStreamWriter = new StreamWriter(myRequestStream, Encoding.UTF8);
myStreamWriter.Write(jxy_parameter);
//把数据写入HttpWebRequest的Request流
myStreamWriter.Close();
myRequestStream.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream, Encoding.UTF8);
//CookieContainer inet = request.CookieContainer;
//string cookie = response.Headers.Get("Set-Cookie");
string resultPage = reader.ReadToEnd();
return resultPage;
}
MessageBox.Show(PostForm("http://www.juxiangyou.com/login/auth HTTP/1.1", textBox1.Text, textBox2.Text, textBox3.Text));
|
|