|  | 
 
| 返回的提示是这样的: ({"username":"\u8bf7\u5237\u65b0\u9875\u9762\u540e\u91cd\u65b0\u63d0\u4ea4"})
 ({"username":"请刷新页面后重新提交"})
 多人判断是cookie错了,
 这个cookie该怎么带呢?类型错了吗
 源码的下载地址
 http://www.sufeinet.com/thread-12101-1-1.html
 
 
 
 
 代码如下
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Data;
 using System.Drawing;
 using System.Linq;
 using System.Text;
 using System.Windows.Forms;
 using CsharpHttpHelper;
 using System.Net;
 using CsharpHttpHelper.Enum;
 using System.Text.RegularExpressions;
 using System.Web;
 namespace 京东测试
 {
 public partial class Form1 : Form
 {
 HttpHelper http = new HttpHelper();
 HttpItem item = null;
 
 HttpResult result = null;
 
 string Cookie = "";
 string retCode = "";
 string uuid;
 string param;
 public Form1()
 {
 InitializeComponent();
 }
 
 private void button1_Click(object sender, EventArgs e)
 {
 
 if (txtUser.Text == "" || txtPass.Text == "") return;
 var r = new Random().NextDouble(); //随机数字
 //创建Httphelper参数对象
 item = new HttpItem()
 {
 URL = "https://passport.jd.com/uc/login?ltype=logout",//URL     必需项
 Method = "get",//URL     可选项 默认为Get
 ContentType = "text/html",//返回类型    可选项有默认值
 };
 //请求的返回值对象
 result = http.GetHtml(item);
 //获取请请求的Html
 string html = result.Html;
 //获取请求的Cookie
 Cookie = result.Cookie; //得到cookie
 result = http.GetHtml(item);
 retCode = result.Html;
 uuid = HttpHelper.GetBetweenHtml(retCode, "uuid\" value=\"", "\"");
 param = getstring(retCode);
 
 
 var ReturnUrl = "http%3A%2F%2Fvip.jd.com%2F";
 var version = "2015";
 item = new HttpItem()
 {
 URL = "https://passport.jd.com/uc/loginService?uuid="+ uuid+"&ReturnUrl="+ReturnUrl+"&r="+r+"&version="+ version,
 Method = "POST",
 //Referer = "https://passport.jd.com/uc/login?ltype=logout",
 Referer = "http://passport.jd.com/new/login.aspx?ReturnUrl=http%3A%2F%2Fvip.jd.com%2F",
 Accept = "*/*",
 Postdata = "uuid=" + uuid + "&loginname=" + txtUser.Text + "&nloginpwd=" + txtPass.Text + "&loginpwd=" + txtPass.Text + "&machineNet=&machineCpu=&machineDisk=&authcode=&" + param,
 Cookie = Cookie, //在请求页面使用这个值
 Allowautoredirect=true,
 ContentType  = "application/x-www-form-urlencoded",
 Timeout = 200000,
 ReadWriteTimeout = 100000
 
 };
 
 item.Header.Add("x-requested-with", "XMLHttpRequest");
 item.Header.Add("Accept-Encoding", "gzip, deflate");
 
 result = http.GetHtml(item);
 Cookie += result.Cookie;
 retCode = result.Html;
 if (retCode.Contains("\\u9a8c\\u8bc1\\u7801\\u4e0d\\u6b63\\u786e\\u6216\\u9a8c\\u8bc1\\u7801\\u5df2\\u8fc7\\u671f"))
 {
 MessageBox.Show("验证码不正确或验证码已过期");
 
 }
 else if (retCode.Contains("({\"success\":\"http://www.jd.com"))
 MessageBox.Show("登录成功!");
 else if (retCode.Contains("\\u8bf7\\u5237\\u65b0\\u9875\\u9762\\u540e\\u91cd\\u65b0\\u63d0\\u4ea4"))
 MessageBox.Show("请刷新页面后重新提交!");都返回这个值
 else
 MessageBox.Show("未知错误!");
 
 }
 
 
 
 
 
 | 
 |