Authored by 陈峰

commit

... ... @@ -27,7 +27,7 @@ const task = async(options, tick = 1) => {
json: true,
headers: {
Accept: 'application/json, text/plain, */*',
appVersion: '3.4.2',
appVersion: '3.5.0',
Referer: 'http://du.hupu.com/mdu/product/detail.html?id=1&source=boutiqueRecommend',
'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'
... ...
const spider = require('../libs/spider');
const _ = require('lodash');
const spiderTask = async ids => {
spider(ids).forEach(promise => promise.then(result => {
spider(ids, 'http://du.hupu.com/mapi/product/detail', {}, 1).forEach(promise => promise.then(result => {
if (result.status === 200) {
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 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 allIds = Array.from(new Array(21500)).map((v, i) => i + 1)
const data = require('../data/skns.json')
const allIds = Array.from(new Array(23000 - 3377)).map((v, i) => i + 3377 + 1)
spiderTask(allIds)
\ No newline at end of file
spiderTask(data.map(item => item.productId))
\ No newline at end of file
... ...