火车头采集js赋值的数据的解决办法
某些需要采集的数据是通过JS赋值的,通常可以抓包来获取真实的地址,但是有些数据是通过JS计算得出的数据,比如:有商品价格,有优惠率然后通过JS计算得出,优惠后的价格并显示到页面某个元素上。这种通过抓包就不行了,这种问题应该跟踪JS,找到相应的计算公式和相应的参数值。最后采集相应的参数值,后期再根据公式计算需要的值。思路大概是这样的,但是跟踪JS我不会啊,请JS高手帮帮忙,看看这个问题怎么解决。
案例:采集“http://item.wanggou.com/6E5AF632000000000401000035068DFA?PTAG=32638.9.40”这个页面的微信扫描优惠价格“4.34元”。 不知道呢、。:(:(:( 本帖最后由 phickers 于 2014-4-26 09:59 编辑
kiahs 发表于 2014-4-24 17:34 static/image/common/back.gif
不知道呢、。
现在取得了较大进展,跟踪到了以下JS代码:BA.twoBarCode.getPhoto = function(size) {
var checked = '',
param = '',
id = window.pageMess && window.pageMess.commodityId || '';
size = parseInt(size) || 82;
this.updateCommAttr(null, null);
if (!$('#stockString').val()) {
checked = 1;
} else {
checked = $('#commodityattr').val() ? '1': '0';
}
param = $.param({
checked: checked,
commlist: this.dom.commAttr.val() || ''
});
return 'http://bases.paipai.com/pay/qrcode?scene=item&id=' + id + '&size=' + size + '¶m=' + escape(param);
};
BA.twoBarCode.showDiscount = function(curPrice) {
curPrice = String(curPrice || '').replace(/[^\d.\-]+/g, '');
var _dom = this.dom,
discount = this.discount / 10,
priceArea = curPrice.split('-'),
price = parseFloat(priceArea) || 0.01,
priceHigh = parseFloat(priceArea) || 0,
html = '方便快捷',
amount = 0,
haveDiscount = 0;
if (1 == discount || _dom.discount.size() == 0) {
console.log('不计算价格:', discount, _dom.discount.size());
return;
}
haveDiscount = $arithmetic().subtract(1, discount);
if (0 == priceHigh) {
amount = $arithmetic().multiply(price, haveDiscount);
amount = Math.floor(amount * 100) / 100;
if (amount > 0) {
html = '立即再减<i>' + amount + '元</i>';
}
} else {
amount = $arithmetic().multiply(priceHigh, haveDiscount);
amount = Math.floor(amount * 100) / 100;
if (amount > 0) {
html = '最多再减<i>' + amount + '元</i>';
}
}
_dom.discount.html(',' + html);
_dom.discountActive.html(',' + html).find('i').css({
backgroundColor: '#D70000',
color: '#fff',
padding: '0 3px'
});
};
})();
if (!PP.c2ccommodity.buyareaV5.isInit) {
PP.c2ccommodity.buyareaV5.init();
}请帮忙分析一下! 问题解决了,算法是:微信优惠=(1-优惠折扣*0.1)*促销价,优惠折扣和促销价在源码中都找的到的。
页:
[1]