本帖最后由 tinsea 于 2014-1-22 20:49 编辑
本人初学者,希望得到大家的帮助,谢谢呀!!!
[C#] 纯文本查看 复制代码 HttpItem itemLogin = new HttpItem()
{
URL="https://passport.jd.com/new/login.aspx",
ResultCookieType = ResultCookieType.CookieCollection,
};
HttpHelper httpLogin = new HttpHelper();
HttpResult resultLogin = httpLogin.GetHtml(itemLogin);
CookiesGlobal = resultLogin.Cookie;
string cookie = resultLogin.Cookie;
string Uuid = Regex.Match(resultLogin.Html, "(?<=uuid.*?value=\").*\"").Value.Replace("\"", "");
string MachineNet = "";
string MachineCpu = "";
string MachineDisk = "";
string Authcode = "";
string HiddenName = Regex.Match(resultLogin.Html, "clr.*?hidden.*?name=\"(\\w+)").Groups[1].Value;
string HiddenValue = Regex.Match(resultLogin.Html, "clr.*?hidden.*?value=\"(\\w+)").Groups[1].Value;
HttpItem itemPost = new HttpItem()
{
URL = "https://passport.jd.com/uc/loginService?uuid=" + Uuid + "&r=0.5113155191183683",
Method = "POST",
Cookie = resultLogin.Cookie,
ContentType = "application/x-www-form-urlencoded",
Referer = "https://passport.jd.com/new/login.aspx",
Postdata = String.Format("uuid={0}&loginname={1}&nloginpwd={2}&loginpwd={3}&machineNet={4}&machineCpu={5}&machineDisk={6}&authcode={7}&{8}={9}", Uuid, User, Pwd, Pwd, MachineNet, MachineCpu, MachineDisk, Authcode, HiddenName, HiddenValue),
};
HttpResult result = httpLogin.GetHtml(itemPost);
string strcookie= result.Cookie;
请求后返回 ({"success":"http://www.jd.com"}) ,应该是登陆成功了。
而后请求我的订单: http://jd2008.jd.com/JdHome/OrderList.aspx
[C#] 纯文本查看 复制代码 itemPost = new HttpItem()
{
URL = "http://jd2008.jd.com/JdHome/OrderList.aspx",
Cookie = strcookie,
};
返回 [HTML] 纯文本查看 复制代码 <html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="http://passport.jd.com/new/login.aspx?ReturnUrl=%2fJdHome%2fOrderList.aspx">here</a>.</h2>
</body></html>
不知道哪里出了问题。
--------------------------------
有时候网页返回的是这种内容 \u8bf7\u5237\u65b0\u9875\u9762\u540e\u91cd\u65b0\u63d0\u4ea4 怎么把他转为汉字。
|