mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-19 09:52:21 +08:00
fix: xiaomi youpin, close #4108
This commit is contained in:
+1
-1
@@ -211,7 +211,7 @@ For instance, in https://www.leboncoin.fr/recherche/?**category=10&locations=Par
|
||||
|
||||
### 小米有品每日上新
|
||||
|
||||
<Route author="xyqfer" example="/mi/youpin/new" path="/mi/youpin/new"/>
|
||||
<Route author="xyqfer DIYgod" example="/mi/youpin/new" path="/mi/youpin/new"/>
|
||||
|
||||
## 宜家 IKEA
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
const got = require('@/utils/got');
|
||||
const utils = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await got({
|
||||
@@ -7,12 +6,34 @@ module.exports = async (ctx) => {
|
||||
url: 'https://home.mi.com/lasagne/page/5',
|
||||
});
|
||||
|
||||
const data = response.data.floors;
|
||||
const data = response.data.floors.filter((floor) => floor.floor_id === 99 || floor.floor_id === 100);
|
||||
const item = data.reduce((acc, item) => {
|
||||
if (!item.data) {
|
||||
return acc;
|
||||
}
|
||||
let goodsList = [];
|
||||
|
||||
if (item.data.result) {
|
||||
goodsList = item.data.result.goods_list;
|
||||
}
|
||||
|
||||
goodsList.forEach((goods) => {
|
||||
const img = goods.pic_url;
|
||||
acc.push({
|
||||
title: goods.name,
|
||||
description: `<img src="${img}"><br>${goods.summary}<br>价格:${goods.market_price / 100}元`,
|
||||
link: goods.jump_url,
|
||||
pubDate: new Date(goods.first_release_time * 1000).toUTCString(),
|
||||
});
|
||||
});
|
||||
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '小米有品众筹',
|
||||
link: 'https://home.mi.com/crowdfunding?&pageid=5',
|
||||
link: 'https://m.xiaomiyoupin.com/w/crowdfunding?pageid=5',
|
||||
description: '小米有品众筹',
|
||||
item: utils.generateData(data),
|
||||
item,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,18 +1,40 @@
|
||||
const got = require('@/utils/got');
|
||||
const utils = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: 'https://home.mi.com/lasagne/page/4',
|
||||
url: 'https://home.mi.com/lasagne/page/1605',
|
||||
});
|
||||
|
||||
const data = response.data.floors;
|
||||
const data = response.data.floors.filter((floor) => floor.floor_id === 25912);
|
||||
const item = data.reduce((acc, item) => {
|
||||
if (!item.data) {
|
||||
return acc;
|
||||
}
|
||||
let goodsList = [];
|
||||
|
||||
if (item.data.result) {
|
||||
goodsList = item.data.result.list;
|
||||
}
|
||||
|
||||
goodsList.forEach((goods) => {
|
||||
const item = goods.value.goods;
|
||||
const img = item.pic_url;
|
||||
acc.push({
|
||||
title: item.name,
|
||||
description: `<img src="${img}"><br>${item.summary}<br>价格:${item.market_price / 100}元`,
|
||||
link: item.jump_url,
|
||||
pubDate: new Date(item.first_release_time * 1000).toUTCString(),
|
||||
});
|
||||
});
|
||||
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '小米有品每日上新',
|
||||
link: 'https://home.mi.com/newproduct?pageid=4',
|
||||
link: 'https://m.xiaomiyoupin.com/w/newproduct?pageid=1605',
|
||||
description: '小米有品每日上新',
|
||||
item: utils.generateData(data),
|
||||
item,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
module.exports = {
|
||||
generateData: (data) =>
|
||||
data.reduce((acc, item) => {
|
||||
if (!item.data) {
|
||||
return acc;
|
||||
}
|
||||
let goodsList = [];
|
||||
|
||||
if (item.data.result) {
|
||||
goodsList = item.data.result.goods_list;
|
||||
} else if (item.data.tabs) {
|
||||
goodsList = item.data.tabs.reduce((acc, tab) => {
|
||||
if (tab.result) {
|
||||
tab.result.goods_list.forEach((goods) => goods);
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, []);
|
||||
}
|
||||
|
||||
goodsList.forEach((goods) => {
|
||||
const img = goods.pic_url;
|
||||
acc.push({
|
||||
title: goods.name,
|
||||
description: `<img src="${img}"><br>${goods.summary}<br>价格:${goods.market_price / 100}元`,
|
||||
link: goods.jump_url,
|
||||
pubDate: new Date(goods.first_release_time * 1000).toUTCString(),
|
||||
});
|
||||
});
|
||||
|
||||
return acc;
|
||||
}, []),
|
||||
};
|
||||
Reference in New Issue
Block a user