抓取苏宁商品价格

·

1 min read

获取商品价格,需要把这个页面中的所有规格 和店铺请求,有点变态~

 https://icps.suning.com/icps-web/getVarnishAllPriceNoCache/000000011451952105,000000011451932139,000000011451844909,000000011451844355,000000011452082076,000000011452070780,000000011451844388,000000011451987921,000000011451954538,000000011451844870,000000011451987939,000000011451987920,000000011451844889,000000011451844861,000000011451987854,000000011625811475,000000011619122999,000000011452060814,000000011925961394_592_5920199_0070993501,0070993501,0070993501,0070993501,0070993501,0070993501,0070993501,0070993501,0070993501,0070993501,0070993501,0070993501,0070993501,0070993501,0070993501,0070993501,0070993501,0070993501,0070993501_1_getClusterPrice.jsonp?callback=getClusterPrice

获取所有规格

       preg_match("/colorList\":(.*), \"pic/", $data, $json);

先获取到商品价格。

获取优惠券信息:

https://icps.suning.com/icps-web/queryExtendedGift/000000011451952105_0070993501_592_5920199_84.90_0_11_1_3,30_pds__0_.vhtm

查看js源码:

b=sn.icpsDomain+"/icps-web/queryExtendedGift/"+g.partNumber+"_"+f+"_"+sn.lesCityId+"_"+c+"_"+g.price+"_"+g.type+"_"+sn.liquanCount+"_1_"+a+"_pds_"+i+"_"+j+"_"+g.custNo+"_"+k+"_"+h+"_"+e+g.callBack+".vhtm

第一个参数: partNumber

第二参数: shop_code

第三参数:可以是区域id : 592

第四参数: c 不懂是啥 592_5920199 ,可能和地区有关 ,我试了好几个商品都是一样,我这么联想 厦门的区号是0592 ,0119 可能是区的编号,就暂且写死吧

第五参数: 当前商品价格

第六参数: g.type 是0 ,不懂是啥

第七参数: liquanCount 可以在主页面中爬取

第八参数: 估计他自己都不知道,固定写1

第九参数 :3,30 不知道是啥,修改了无影响 ,可能3月30号是个值得纪念的日子

第十参数: pds 不知道是啥,可以随便修改

总之,后面的几个参数,好像目前来看没什么影响

单规格

https://pas.suning.com/nspcsale_0_000000012216019804_000000012216019804_0071351044_1_592_5920199_______.html

解析json中的函数:

$json_content = str_replace('function_name(', '', file_get_contents($source)); 
$json_content = substr($json_content,0,-2); 
$json = json_decode($json_content,true); 
echo $json['one']['value'];