http://www.sufeinet.com/plugin.php?id=keke_group

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

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

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

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

查看: 11294|回复: 5

[例子] 使用Httphelper获取京东(jd.com)商品价格

[复制链接]
发表于 2014-12-3 21:43:56 | 显示全部楼层 |阅读模式
比如要获取这个商品的价格

http://item.jd.com/1178322.html

如果你直接请求这个页面是肯定不行的,因为他的价格是使用Ajax获取的,

网址我找到了直接提供给大家吧

http://d.360buy.com/fittingInfo/ ... mend.cbRecoFittings


看到skuid你应该就明白了,是和上面的数字是对应的,

直接访问这个页面就能提取价格

如下
[C#] 纯文本查看 复制代码
Recommend.cbRecoFittings({"master":{"name":"\u8054\u60f3\uff08Lenovo\uff09 G410AT 14.0\u82f1\u5bf8\u7b14\u8bb0\u672c\u7535\u8111\uff08i5-4210M 4G 500G 2G\u72ec\u663e \u6444\u50cf\u5934 DVD\u523b\u5f55 Win8\uff09\u9ed1\u8272","price":"3599.00","discount":"200.00","pic":"jfs/t610/108/366619818/99109/d4c7122b/54605a2aNf381b1f0.jpg","skuid":"1178322","sort":672},"fittings":[{"name":"\u5de5\u5177","price":"149.00","discount":"150.00","pic":"g12/M00/01/07/rBEQYFMr1mkIAAAAAADJhiB2ueMAADEPgECiMYAAMme574.jpg","skuid":1075420,"sort":1050},{"name":"\u5317\u901a\u963f\u4fee\u7f57SE \u6709\u7ebf\u632f\u52a8\u70ab\u5149\u7248 \u6e38\u620f\u624b\u67c4 \u955c\u9762\u9ed1","price":"119.00","discount":"0.00","pic":"g6/M02/05/0C/rBEGDFDSvUMIAAAAAAE2FnVvEZEAABDPwJDWqIAATYu495.jpg","skuid":783846,"sort":696},{"name":"\u5317\u901a\u963f\u4fee\u7f57TE PC&PS3\u53cc\u5e73\u53f0 \u667a\u80fd\u6e38\u620f\u624b\u67c4 \u955c\u9762\u767d","price":"139.00","discount":"10.00","pic":"g7/M03/07/1E/rBEHZVBlPp4IAAAAAAERal4_IjoAABjmgNeB2EAARGC682.jpg","skuid":737628,"sort":696},{"name":"\u5317\u901a\u77ac\u98ce189 \u96f6\u6b7b\u89d2 \u6e38\u620f\u65b9\u5411\u76d8","price":"299.00","discount":"0.00","pic":"g14/M00/14/13/rBEhVVMVN4EIAAAAAAGA0Hh6ikEAAJg_ACdAboAAYDo073.jpg","skuid":1068234,"sort":696},{"name":"latit\u65f6\u5c1a\u5927\u5bb9\u91cf\u7535\u8111\u5305","price":"99.00","discount":"100.00","pic":"g10/M00/11/06/rBEQWVFbl7sIAAAAAAKRSNUkhPoAADXBQJADvUAApFg411.jpg","skuid":848726,"sort":675},{"name":"\u8d5b\u777f6gv2\u7ea2\u8f74\u673a\u68b0\u952e\u76d8","price":"799.00","discount":"0.00","pic":"jfs/t640/204/223286421/92941/e0a696c0/54574f33Na5cec248.jpg","skuid":692575,"sort":689},{"name":"\u8d5b\u777f\u971c\u51bb\u4e4b\u84dd\u8033\u673a","price":"829.00","discount":"40.00","pic":"g1/M02/06/12/rBEGDlAWIx0IAAAAAAEpxCvzp7kAABSFwGt8EMAASnc458.jpg","skuid":692632,"sort":696},{"name":"\u8d5b\u777f\u971c\u51bb\u4e4b\u84dd\u9f20\u6807","price":"399.00","discount":"40.00","pic":"g9/M01/12/1D/rBEHaVD82KoIAAAAAACYd8GTiJMAADsnAFPA-AAAJiP102.jpg","skuid":805716,"sort":690},{"name":"\u8d5b\u777fQCK+\u539a\u8d28\u5927\u53f7\u9f20\u6807\u57ab","price":"129.00","discount":"0.00","pic":"240/8c5be7ab-e264-4143-a27f-35629c471b59.jpg","skuid":536515,"sort":826},{"name":"\u952e\u76d8\u4fdd\u62a4\u819c","price":"23.90","discount":"0.00","pic":"g13/M02/10/1C/rBEhU1LOXQoIAAAAAAFKJY3pT2oAAHw7gJ9y5QAAUo9114.jpg","skuid":394238,"sort":675},{"name":"\u739b\u96c5\uff08MAYA\uff09\u65c5\u884c\u4e07\u7528\u8f6c\u6362\u63d2\u5934/USB\u5145\u7535\u5668/\u5168\u7403216\u4e2a\u56fd\u5bb6\u9002\u7528 \u767d\u8272","price":"59.90","discount":"10.00","pic":"g5/M02/13/12/rBEIC0_7h_sIAAAAAAC8XqqSiMgAAD0ugCCodcAALx2566.jpg","skuid":534127,"sort":1047},{"name":"\u98de\u5229\u6d66\uff08PHILIPS\uff09\u9632\u96f7\u6ee4\u6ce2\u7a33\u538b\u7535\u6e90\u51c0\u5316\u63d2\u5ea7 \u9632\u706b\u8282\u80fd38\u4f4d\u72ec\u7acb\u5f00\u5173","price":"59.90","discount":"39.10","pic":"jfs/t595/31/600715343/40967/9ac43e5c/54730aa9N4c6a7f70.jpg","skuid":1108623,"sort":1047},{"name":"\u60a8\u7684\u7535\u8111\u5b89\u5168\u5417","price":"99.00","discount":"50.00","pic":"jfs/t343/100/879558026/73360/760557b8/542776d2N70c36e32.jpg","skuid":314666,"sort":675}],"fittingType":[{"sort":1050,"name":"\u7535\u8111\u5de5\u5177","number":1},{"sort":696,"name":"\u6e38\u620f\u8bbe\u5907","number":4},{"sort":690,"name":"\u9f20\u6807","number":1},{"sort":675,"name":"\u7b14\u8bb0\u672c\u914d\u4ef6","number":3},{"sort":1047,"name":"\u63d2\u5ea7","number":2},{"sort":826,"name":"\u9f20\u6807\u57ab","number":1},{"sort":689,"name":"\u952e\u76d8","number":1}]})

"price":"119.00",这个就是,其他的大家看情况需要的就用不需要无视之

使用Httphelper提取的方法如下

[C#] 纯文本查看 复制代码
  HttpHelper http = new HttpHelper();
            HttpItem item = new HttpItem()
            {
                URL = "http://d.360buy.com/fittingInfo/get?skuId=1178322&callback=Recommend.cbRecoFittings",//URL     必需项 
                ContentType = "text/html",//返回类型    可选项有默认值 
                ResultType = ResultType.String
            };
            HttpResult result = http.GetHtml(item);
            string html = result.Html;
            string cookie = result.Cookie;


直接分析Html就行了。






1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
发表于 2014-12-8 13:27:21 | 显示全部楼层
受教了学习中……
发表于 2014-12-10 20:39:04 | 显示全部楼层
关键是怎么找到查询价格的连接,具体是怎么找到的,楼主,能说下大概思路吗?
 楼主| 发表于 2014-12-10 20:56:17 | 显示全部楼层
抓包,个的检查,没几个连接
发表于 2014-12-16 21:22:20 | 显示全部楼层
受教了学习中……
发表于 2015-3-23 01:37:14 | 显示全部楼层
感谢您的无私奉献,真是帮了我的大忙了
您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

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

GMT+8, 2024-12-23 00:15

© 2014-2021

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