mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 23:00:48 +08:00
feat: Add “Arknights” game official news channel (#2670)
* Add “Arknights” game official news channel * Update docs for new “Arknights” channel * Fix cache issue with “Arknights” channel * Update document in standard format * Update document in standard format
This commit is contained in:
@@ -185,6 +185,12 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的
|
||||
|
||||
</Route>
|
||||
|
||||
## 明日方舟
|
||||
|
||||
### 游戏公告与新闻
|
||||
|
||||
<Route author="Astrian" example="/arknights/news" path="/arknights/news"/>
|
||||
|
||||
## 小黑盒
|
||||
|
||||
### 用户动态
|
||||
|
||||
@@ -1531,4 +1531,7 @@ router.get('/codeceo/:type/:category?', require('./routes/codeceo/category'));
|
||||
// BOF
|
||||
router.get('/bof/home', require('./routes/bof/home'));
|
||||
|
||||
// 《明日方舟》游戏
|
||||
router.get('/arknights/news', require('./routes/arknights/news'));
|
||||
|
||||
module.exports = router;
|
||||
|
||||
51
lib/routes/arknights/news.js
Normal file
51
lib/routes/arknights/news.js
Normal file
@@ -0,0 +1,51 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: 'https://ak.hypergryph.com/news.html',
|
||||
});
|
||||
|
||||
let newslist = response.data;
|
||||
|
||||
const $ = cheerio.load(newslist);
|
||||
newslist = $('#news > div > div.news-block > ul:first-child > li');
|
||||
|
||||
newslist = await Promise.all(
|
||||
newslist
|
||||
.map(async (index, item) => {
|
||||
const sth = $(item);
|
||||
const link = `https://ak.hypergryph.com${sth
|
||||
.find('a')
|
||||
.attr('href')
|
||||
.slice(1)}`;
|
||||
const description = await ctx.cache.tryGet(link, async () => {
|
||||
const result = await got.get(link);
|
||||
const $ = cheerio.load(result.data);
|
||||
return $('.article-inner').html();
|
||||
});
|
||||
return {
|
||||
title: sth
|
||||
.find('.news-title')
|
||||
.first()
|
||||
.text(),
|
||||
description,
|
||||
link,
|
||||
pubDate: new Date(
|
||||
sth
|
||||
.find('.news-date-text')
|
||||
.first()
|
||||
.text()
|
||||
),
|
||||
};
|
||||
})
|
||||
.get()
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '《明日方舟》游戏公告与新闻',
|
||||
link: 'https://ak.hypergryph.com/news.html',
|
||||
item: newslist,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user