mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-07 13:39:35 +08:00
@@ -2422,6 +2422,8 @@ IATA 国际航空运输协会机场代码, 参见[维基百科 国际航空运
|
|||||||
|
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
|
<route name="好文" author="LogicJake" example="/smzdm/haowen/1" path="/smzdm/haowen/:day" :paramsDesc="['以天为时间跨度,默认为all,其余可以选择1,7,30,365']"/>
|
||||||
|
|
||||||
### 小米
|
### 小米
|
||||||
|
|
||||||
<route name="小米众筹" author="DIYgod" example="/mi/crowdfunding" path="/mi/crowdfunding"/>
|
<route name="小米众筹" author="DIYgod" example="/mi/crowdfunding" path="/mi/crowdfunding"/>
|
||||||
|
|||||||
@@ -374,6 +374,7 @@ router.get('/eztv/torrents/:imdb_id', require('./routes/eztv/imdb'));
|
|||||||
// 什么值得买
|
// 什么值得买
|
||||||
router.get('/smzdm/keyword/:keyword', require('./routes/smzdm/keyword'));
|
router.get('/smzdm/keyword/:keyword', require('./routes/smzdm/keyword'));
|
||||||
router.get('/smzdm/ranking/:rank_type/:rank_id/:hour', require('./routes/smzdm/ranking'));
|
router.get('/smzdm/ranking/:rank_type/:rank_id/:hour', require('./routes/smzdm/ranking'));
|
||||||
|
router.get('/smzdm/haowen/:day?', require('./routes/smzdm/haowen'));
|
||||||
|
|
||||||
// 新京报
|
// 新京报
|
||||||
router.get('/bjnews/:cat', require('./routes/bjnews/news'));
|
router.get('/bjnews/:cat', require('./routes/bjnews/news'));
|
||||||
|
|||||||
62
lib/routes/smzdm/haowen.js
Normal file
62
lib/routes/smzdm/haowen.js
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
const axios = require('../../utils/axios');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const date = require('../../utils/date');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const day = ctx.params.day || 'all';
|
||||||
|
const link = `https://post.smzdm.com/hot_${day}`;
|
||||||
|
|
||||||
|
const response = await axios.get(link);
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
const title = $('li.filter-tab.active').text();
|
||||||
|
|
||||||
|
const list = $('li.feed-row-wide')
|
||||||
|
.slice(0, 10)
|
||||||
|
.map(function() {
|
||||||
|
const info = {
|
||||||
|
title: $(this)
|
||||||
|
.find('h5.z-feed-title a')
|
||||||
|
.text(),
|
||||||
|
link: $(this)
|
||||||
|
.find('h5.z-feed-title a')
|
||||||
|
.attr('href'),
|
||||||
|
pubdate: $(this)
|
||||||
|
.find('span.z-publish-time')
|
||||||
|
.text(),
|
||||||
|
};
|
||||||
|
return info;
|
||||||
|
})
|
||||||
|
.get();
|
||||||
|
|
||||||
|
const out = await Promise.all(
|
||||||
|
list.map(async (info) => {
|
||||||
|
const title = info.title;
|
||||||
|
const pubdate = info.pubdate;
|
||||||
|
const itemUrl = info.link;
|
||||||
|
|
||||||
|
const cache = await ctx.cache.get(itemUrl);
|
||||||
|
if (cache) {
|
||||||
|
return Promise.resolve(JSON.parse(cache));
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await axios.get(itemUrl);
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
const description = $('article > div').html();
|
||||||
|
|
||||||
|
const single = {
|
||||||
|
title: title,
|
||||||
|
link: itemUrl,
|
||||||
|
description: description,
|
||||||
|
pubDate: date(pubdate),
|
||||||
|
};
|
||||||
|
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||||
|
return Promise.resolve(single);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: `${title}-什么值得买好文`,
|
||||||
|
link: link,
|
||||||
|
item: out,
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user