京东模拟登录步骤
第一步:获取登录页面基础值
第二步:判断是否需要验证码
第三步:拼装提交信息
第四步:提交数据到指定服务
第五步:获取返回信息
登录代码: HttpItem item = new HttpItem();
HttpHelper helper = new HttpHelper();
HttpResult result = new HttpResult();
item.URL = string.Format("https://passport.jd.com/uc/loginService?uuid={0}&&r={1}&version=2015", _jdLoginer.uuid, _jdLoginer.r);
item.Method = "post";
item.Allowautoredirect = true;
item.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
item.Postdata = string.Format("uuid={0}&machineNet=&machineCpu=&machineDisk=&eid={1}&fp={2}&{3}={4}"
+ "&loginname={5}&nloginpwd={6}&loginpwd={6}&chkRememberMe=on&authcode=",
_jdLoginer.uuid, _jdLoginer.eid, _jdLoginer.fp, _jdLoginer.tname, _jdLoginer.tvalue, _jdLoginer.loginname,_jdLoginer.loginpwd);
item.Header.Add("x-requested-with", "XMLHttpRequest");
item.Header.Add("Accept-Encoding", "gzip, deflate");
item.Accept = "*/*";
item.Encoding = Encoding.UTF8;
item.Cookie = cookies;
result = helper.GetHtml(item);
if (!result.Html.Contains("success"))
{
if (result.Html.ToLower().Contains("pwd"))
{
MessageBox.Show("密码验证不通过!", "系统提示");
return;
}
else if (result.Html.ToLower().Contains("emptyauthcode"))
{
MessageBox.Show("请输入登录验证码!", "系统提示");
return;
}
else
{
MessageBox.Show("登陆失败!" + result.Html, "系统提示");
}
}
else
{
MessageBox.Show("登录京东商城成功!", "系统提示");
}
做最走心的京东监控软件 免费开源的监控软件 欢迎加入QQ群751229947一起讨论