spider.js
1.04 KB
const spider = require('../libs/spider');
const _ = require('lodash');
const spiderTask = async ids => {
spider(ids, 'http://du.hupu.com/mapi/product/detail', {}, 1).forEach(promise => promise.then(result => {
if (result.status === 200) {
const sizes = result.data.sizeList;
sizes.forEach(size => {
const price = size.item.price;
const prePrice = _.get(size, 'preSellItem.price', 0)
const showPrice = _.get(size, 'showItem.price', 0)
console.log(`${result.data.detail.productId},${size.size},${price/100 || 0},${prePrice/100},${showPrice/100}`)
})
// console.log(`${result.data.detail.productId},${result.data.detail.articleNumber},${result.data.detail.title},${result.data.item.price / 100},${result.data.detail.soldNum},http://du.hupu.com/mdu/product/detail.html?id=${result.data.detail.productId}`);
}
}))
}
const data = require('../data/skns.json')
const allIds = Array.from(new Array(23000 - 3377)).map((v, i) => i + 3377 + 1)
spiderTask(data.map(item => item.productId))