diff --git a/docs/README.md b/docs/README.md
index 30469db12..d72d1eede 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -2298,9 +2298,9 @@ IATA 国际航空运输协会机场代码, 参见[维基百科 国际航空运
-| 正在流行 | 24 小时最佳 |
-| -------- | ----------- |
-| hot | pop |
+| 正在流行 | 24 小时最佳 | 本周最受欢迎 | 新秀菜谱 | 月度最佳 |
+| -------- | ----------- | ------------ | -------- | ---------- |
+| hot | pop | week | rising | monthhonor |
diff --git a/routes/xiachufang/utils.js b/routes/xiachufang/utils.js
index 54c09ebd8..3fbbc7fe2 100644
--- a/routes/xiachufang/utils.js
+++ b/routes/xiachufang/utils.js
@@ -1,33 +1,44 @@
const axios = require('../../utils/axios');
const cheerio = require('cheerio');
-const generateItems = ($) =>
- $('.ias-container .pure-u')
+const generateItems = ($, timeframe) => {
+ let selector;
+ if (['week', 'rising', 'monthhonor'].includes(timeframe)) {
+ selector = '.normal-recipe-list li';
+ } else {
+ selector = '.ias-container .pure-u';
+ }
+
+ return $(selector)
.map(function() {
const $item = $(this);
const $link = $item.find('.name a');
const title = $link.text();
const link = `https://www.xiachufang.com${$link.attr('href')}`;
- const desc = $item
- .find('.desc')
- .text()
- .replace(/\n/g, '
');
const img = $item
.find('.cover img')
.attr('data-src')
.replace(/\?.+/g, '');
+ let desc = $item.find('.ing').text();
+ if (!desc || desc === '') {
+ desc = $item
+ .find('.desc')
+ .text()
+ .replace(/\n/g, '
');
+ }
return {
title,
link,
description: `
- 
- ${title}
- ${desc}
- `,
+ 
+ ${title}
+ ${desc}
+ `,
};
})
.get();
+};
const fetchPage = (url) =>
axios({
@@ -60,15 +71,38 @@ module.exports = {
'': '最新上传',
hot: '正在流行',
pop: '24小时最佳',
+ week: '本周最受欢迎',
+ rising: '新秀菜谱',
+ monthhonor: '月度最佳',
};
- const url = `https://www.xiachufang.com/activity/site/?order=${timeframe}`;
+ let url;
+
+ switch (timeframe) {
+ case 'hot':
+ case 'pop':
+ url = `https://www.xiachufang.com/activity/site/?order=${timeframe}`;
+ break;
+
+ case 'rising':
+ case 'monthhonor':
+ url = `https://www.xiachufang.com/explore/${timeframe}/`;
+ break;
+
+ case 'week':
+ url = 'https://www.xiachufang.com/explore/';
+ break;
+
+ default:
+ url = 'https://www.xiachufang.com/activity/site/?order=';
+ }
+
const response = await fetchPage(url);
const $ = cheerio.load(response.data);
return {
title: `下厨房-${mapper[timeframe]}`,
link: url,
- item: generateItems($),
+ item: generateItems($, timeframe),
};
},
};