找回密码

火车采集器软件交流官方论坛

搜索
火车采集器V9版免费下载火车浏览器 - 可视采集,万能群发,全自动脚本工具
查看: 4115|回复: 3

火车头采集js赋值的数据的解决办法

[复制链接]
发表于 2014-4-24 12:54:17 | 显示全部楼层 |阅读模式
某些需要采集的数据是通过JS赋值的,通常可以抓包来获取真实的地址,但是有些数据是通过JS计算得出的数据,比如:有商品价格,有优惠率然后通过JS计算得出,优惠后的价格并显示到页面某个元素上。这种通过抓包就不行了,这种问题应该跟踪JS,找到相应的计算公式和相应的参数值。最后采集相应的参数值,后期再根据公式计算需要的值。


思路大概是这样的,但是跟踪JS我不会啊,请JS高手帮帮忙,看看这个问题怎么解决。

案例:采集“http://item.wanggou.com/6E5AF632000000000401000035068DFA?PTAG=32638.9.40”这个页面的微信扫描优惠价格“4.34元”。
发表于 2014-4-24 17:34:19 | 显示全部楼层
不知道呢、。
 楼主| 发表于 2014-4-24 18:38:27 | 显示全部楼层
本帖最后由 phickers 于 2014-4-26 09:59 编辑
kiahs 发表于 2014-4-24 17:34
不知道呢、。


现在取得了较大进展,跟踪到了以下JS代码:
  1. BA.twoBarCode.getPhoto = function(size) {
  2.         var checked = '',
  3.         param = '',
  4.         id = window.pageMess && window.pageMess.commodityId || '';
  5.         size = parseInt(size) || 82;
  6.         this.updateCommAttr(null, null);
  7.         if (!$('#stockString').val()) {
  8.             checked = 1;
  9.         } else {
  10.             checked = $('#commodityattr').val() ? '1': '0';
  11.         }
  12.         param = $.param({
  13.             checked: checked,
  14.             commlist: this.dom.commAttr.val() || ''
  15.         });
  16.         return 'http://bases.paipai.com/pay/qrcode?scene=item&id=' + id + '&size=' + size + '&param=' + escape(param);
  17.     };
  18.     BA.twoBarCode.showDiscount = function(curPrice) {
  19.         curPrice = String(curPrice || '').replace(/[^\d.\-]+/g, '');
  20.         var _dom = this.dom,
  21.         discount = this.discount / 10,
  22.         priceArea = curPrice.split('-'),
  23.         price = parseFloat(priceArea[0]) || 0.01,
  24.         priceHigh = parseFloat(priceArea[1]) || 0,
  25.         html = '方便快捷',
  26.         amount = 0,
  27.         haveDiscount = 0;
  28.         if (1 == discount || _dom.discount.size() == 0) {
  29.             console.log('不计算价格:', discount, _dom.discount.size());
  30.             return;
  31.         }
  32.         haveDiscount = $arithmetic().subtract(1, discount);
  33.         if (0 == priceHigh) {
  34.             amount = $arithmetic().multiply(price, haveDiscount);
  35.             amount = Math.floor(amount * 100) / 100;
  36.             if (amount > 0) {
  37.                 html = '立即再减<i>' + amount + '元</i>';
  38.             }
  39.         } else {
  40.             amount = $arithmetic().multiply(priceHigh, haveDiscount);
  41.             amount = Math.floor(amount * 100) / 100;
  42.             if (amount > 0) {
  43.                 html = '最多再减<i>' + amount + '元</i>';
  44.             }
  45.         }
  46.         _dom.discount.html(',' + html);
  47.         _dom.discountActive.html(',' + html).find('i').css({
  48.             backgroundColor: '#D70000',
  49.             color: '#fff',
  50.             padding: '0 3px'
  51.         });
  52.     };
  53. })();
  54. if (!PP.c2ccommodity.buyareaV5.isInit) {
  55.     PP.c2ccommodity.buyareaV5.init();
  56. }
复制代码
请帮忙分析一下!
 楼主| 发表于 2014-4-26 10:02:02 | 显示全部楼层
问题解决了,算法是:微信优惠=(1-优惠折扣*0.1)*促销价,优惠折扣和促销价在源码中都找的到的。
您需要登录后才可以回帖 登录 | 加入会员

本版积分规则

温馨提示:建议您联系官方定制服务,通过官方支付方式完成支付。您与其他非官方账号发生的交易,我方概不承担责任。网络有风险,交易需谨慎

QQ| 手机版|Archiver| 火车采集器官方站

Copyright © 2001-2013 Comsenz Inc.  Template by Comeings! All Rights Reserved.

Powered by Discuz! X3.4( 皖ICP备06000549 )

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