苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

分布式系统框架(V2.0) 轻松承载百亿数据,千万流量!讨论专区 - 源码下载 - 官方教程

HttpHelper爬虫框架(V2.7-含.netcore) HttpHelper官方出品,爬虫框架讨论区 - 源码下载 - 在线测试和代码生成

HttpHelper爬虫类(V2.0) 开源的爬虫类,支持多种模式和属性 源码 - 代码生成器 - 讨论区 - 教程- 例子

查看: 6283|回复: 3

[其他] 飞哥 京东访问我的订单问题求助

[复制链接]
发表于 2014-1-22 17:53:55 | 显示全部楼层 |阅读模式
本帖最后由 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 怎么把他转为汉字。


1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
发表于 2014-1-23 08:33:18 | 显示全部楼层
[C#] 纯文本查看 复制代码
  HttpHelper http = new HttpHelper();
            HttpItem itemLogin = new HttpItem()
            {
                URL = "https://passport.jd.com/new/login.aspx",
                ResultCookieType = ResultCookieType.CookieCollection,
            };
            HttpResult result = http.GetHtml(itemLogin);


            string Uuid = Regex.Match(result.Html, "(?<=uuid.*?value=\").*\"").Value.Replace("\"", "");
            string MachineNet = "";
            string MachineCpu = "";
            string MachineDisk = "";
            string Authcode = "";
            string HiddenName = Regex.Match(result.Html, "clr.*?hidden.*?name=\"(\\w+)").Groups[1].Value;
            string HiddenValue = Regex.Match(result.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",
                CookieCollection = result.CookieCollection,
                ContentType = "application/x-www-form-urlencoded",
                ResultCookieType = ResultCookieType.CookieCollection,
                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),
            };
            result = http.GetHtml(itemPost);

            itemPost = new HttpItem()
            {
                URL = "http://jd2008.jd.com/JdHome/OrderList.aspx",
                CookieCollection = result.CookieCollection,
                ResultCookieType = ResultCookieType.CookieCollection
            };
发表于 2014-1-23 08:30:11 | 显示全部楼层
http://www.sufeinet.com/thread-1401-1-1.html转化的方法在这里
另外不要使用字符串的Cookie试试
ResultCookieType=ResultCookieType.CookieCollection
 楼主| 发表于 2014-1-23 16:32:31 | 显示全部楼层
改成这个,ResultCookieType=ResultCookieType.CookieCollection
然后请求订单页面直接请求 http://order.jd.com/center/list.action?r=635260905480176250
就可以了。
您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

QQ|手机版|小黑屋|手机版|联系我们|关于我们|广告合作|苏飞论坛 ( 豫ICP备18043678号-2)

GMT+8, 2025-1-4 13:23

© 2014-2021

快速回复 返回顶部 返回列表