Authored by 杨延青

Merge branch 'feature/detailApi' into 'master'

change new api



See merge request !1
... ... @@ -4,6 +4,8 @@ const nodeLockup = require('node-lockup');
const chalk = require('chalk');
const {logger} = require('./logger');
const detailUrl = 'https://app.poizon.com/api/v1/h5/index/fire/flow/product/detail';
const sign = (obj) => {
let constr = '';
... ... @@ -25,10 +27,12 @@ const task = async(options, tick = 1) => {
json: true,
headers: {
Accept: 'application/json, text/plain, */*',
appVersion: '3.5.0',
Referer: 'http://du.hupu.com/mdu/product/detail.html?id=1&source=boutiqueRecommend',
appid: 'h5',
appVersion: '4.4.0',
Referer: 'http://du.hupu.com/mdu/product/detail.html?id=1&source=shareDetail',
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 Safari/604.1',
'X-Requested-With': 'XMLHttpRequest'
'X-Requested-With': 'XMLHttpRequest',
cookie: 'duToken=d41d8cd9%7C16075871%7C1558328526%7C37c4ab8a8cd16e3f; UM_distinctid=16a341fe1c86a-099fe9f71aa88b8-5743047f-4a640-16a341fe1c94c5'
},
timeout: 2000
});
... ... @@ -43,20 +47,20 @@ const task = async(options, tick = 1) => {
}
};
module.exports = (ids, url = 'http://du.hupu.com/mapi/product/detail', params, delay) => {
module.exports = (ids, url, params, delay) => {
const lockTask = nodeLockup(task, delay || 1);
return ids.map(id => lockTask(Object.assign({
productId: id,
source: 'boutiqueRecommend',
url
productSourceName: 'shareDetail',
url: url || detailUrl
}, params)));
};
module.exports.spiderFetch = (id, url = 'http://du.hupu.com/mapi/product/detail', params) => {
module.exports.spiderFetch = (id, url, params) => {
return task(Object.assign({
productId: id,
source: 'boutiqueRecommend',
url
productSourceName: 'shareDetail',
url: url || detailUrl
}, params));
};
... ...
... ... @@ -53,7 +53,8 @@ const parseTime = (relativeTime) => {
const spiderBuyers = async(productId, lsId = 0, page = 0, trys = 0) => {
const result = await spider.spiderFetch(productId, 'https://du.hupu.com/mapi/product/lastSoldList', {
const result = await spider.spiderFetch(productId, 'https://app.poizon.com/api/v1/h5/product/fire/lastSoldList'
, {
lastId: lsId
});
... ...