mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 23:00:48 +08:00
feat: Add Sina rollnews (#2064)
This commit is contained in:
@@ -201,6 +201,8 @@ category 对应的关键词有
|
|||||||
|
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
<Route name="滚动新闻" author="xyqfer" example="/sina/rollnews" path="/sina/rollnews" />
|
||||||
|
|
||||||
## 人民日报
|
## 人民日报
|
||||||
|
|
||||||
<Route name="观点" author="LogicJake" example="/people/opinion/223228" path="/people/opinion/:id" :paramsDesc="['板块id,可在 URL 中找到']"/>
|
<Route name="观点" author="LogicJake" example="/people/opinion/223228" path="/people/opinion/:id" :paramsDesc="['板块id,可在 URL 中找到']"/>
|
||||||
|
|||||||
@@ -1086,6 +1086,9 @@ router.get('/mpaypass/news', require('./routes/mpaypass/news'));
|
|||||||
// 新浪科技探索
|
// 新浪科技探索
|
||||||
router.get('/sina/discovery/:type', require('./routes/sina/discovery'));
|
router.get('/sina/discovery/:type', require('./routes/sina/discovery'));
|
||||||
|
|
||||||
|
// 新浪科技滚动新闻
|
||||||
|
router.get('/sina/rollnews', require('./routes/sina/rollnews'));
|
||||||
|
|
||||||
// Animen
|
// Animen
|
||||||
router.get('/animen/news/:type', require('./routes/animen/news'));
|
router.get('/animen/news/:type', require('./routes/animen/news'));
|
||||||
|
|
||||||
|
|||||||
40
lib/routes/sina/rollnews.js
Normal file
40
lib/routes/sina/rollnews.js
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
const axios = require('../../utils/axios');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const response = await axios.get(`https://feed.mix.sina.com.cn/api/roll/get?pageid=372&lid=2431&k=&num=50&page=1&r=${Math.random()}&callback=&_=${new Date().getTime()}`);
|
||||||
|
const list = response.data.result.data;
|
||||||
|
|
||||||
|
const out = await Promise.all(
|
||||||
|
list.map(async (data) => {
|
||||||
|
const title = data.title;
|
||||||
|
const date = data.intime * 1000;
|
||||||
|
const link = data.url;
|
||||||
|
|
||||||
|
const description = await ctx.cache.tryGet(
|
||||||
|
`sina-rollnews: ${link}`,
|
||||||
|
async () => {
|
||||||
|
const response = await axios.get(link);
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
|
||||||
|
return $('.article').html();
|
||||||
|
},
|
||||||
|
3 * 60 * 60
|
||||||
|
);
|
||||||
|
|
||||||
|
const single = {
|
||||||
|
title: title,
|
||||||
|
link,
|
||||||
|
description: description,
|
||||||
|
pubDate: new Date(date).toUTCString(),
|
||||||
|
};
|
||||||
|
return Promise.resolve(single);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: '新浪科技滚动新闻',
|
||||||
|
link: 'https://tech.sina.com.cn/roll/rollnews.shtml#pageid=372&lid=2431&k=&num=50&page=1',
|
||||||
|
item: out,
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user