110,499
社区成员
发帖
与我相关
我的任务
分享
string IE = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; BOIE9;ZHCN)";
StringBuilder sb = new StringBuilder();
string postdata = "uuid=492f11d9-e50c-48fa-8533-a734f33a6c2d&loginname="+this.TextBox1.Text+"&nloginpwd="+TextBox2.Text+"&loginpwd="+TextBox2.Text+"&machineNet=&machineCpu=&machineDisk=&authcode=&FvVLaQFOlY=VDvKN";
string Url= "http://passport.jd.com/uc/loginService?uuid=58d51760-e2f8-46eb-a5f5-dbda93cd44b1&&r=0.05565985920839012";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
request.UserAgent = IE;
request.Method = "Post";
request.Accept = "*/*";
//如果方法验证网页来源就加上这一句如果不验证那就可以不写了
request.Referer = "http://passport.jd.com/uc/login";
request.ContentType = "application/x-www-form-urlencoded";
request.AllowAutoRedirect = true;
byte[] Postbyte = Encoding.ASCII.GetBytes(postdata);
request.ContentLength = Postbyte.Length;
Stream newStream = request.GetRequestStream();
newStream.Write(Postbyte, 0, Postbyte.Length);//把参数用流对象写入request对象中
newStream.Close();
/////////////////////////////////
//////Cookie
/////////////////////////////////
//不保持连接
request.KeepAlive = true;
// 获取对应HTTP请求的响应
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
// 获取响应流
Stream responseStream = response.GetResponseStream();
// 对接响应流(以"GBK"字符集)
StreamReader sReader = new StreamReader(responseStream, Encoding.GetEncoding("gb2312"));
// 开始读取数据
Char[] sReaderBuffer = new Char[256];
int count = sReader.Read(sReaderBuffer, 0, 256);
while (count > 0)
{
String tempStr = new String(sReaderBuffer, 0, count);
sb.Append(tempStr);
count = sReader.Read(sReaderBuffer, 0, 256);
}
// 读取结束
sReader.Close();
Response.Write(sb.ToString());