feat(route): 添加gamegene的rss订阅 (#13296)
* 🎨 添加gamegene的rss订阅 * 📝 添加文档 * Update lib/v2/gamegene/radar.js * Update lib/v2/gamegene/radar.js * Update lib/v2/gamegene/radar.js * Update lib/v2/gamegene/radar.js * fix: docs format * Update lib/v2/gamegene/maintainer.js * Update website/docs/routes/game.md * fix: datetime --------- Co-authored-by: wuyi <wuyi@xiaoduotech.com>
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/news': ['lone1y-51'],
|
||||
};
|
||||
@@ -0,0 +1,50 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const url = 'https://gamegene.cn/news';
|
||||
const { data: response } = await got({
|
||||
method: 'get',
|
||||
url,
|
||||
});
|
||||
const $ = cheerio.load(response);
|
||||
const list = $('div.mr245')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
const aEle = item.find('a').first();
|
||||
const href = aEle.attr('href');
|
||||
const title = aEle.find('h3').first().text();
|
||||
const author = item.find('a.namenode').text();
|
||||
const category = item.find('span.r').text();
|
||||
return {
|
||||
title,
|
||||
link: href,
|
||||
author,
|
||||
category,
|
||||
};
|
||||
});
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const { data: response } = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
const $ = cheerio.load(response);
|
||||
const dateTime = $('div.meta').find('time').first().text();
|
||||
item.pubDate = parseDate(dateTime);
|
||||
item.description = $('div.content').first().html();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
// 在此处输出您的 RSS
|
||||
item: items,
|
||||
link: url,
|
||||
title: '游戏基因 GameGene',
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'gamegene.cn': {
|
||||
_name: '游戏基因',
|
||||
news: [
|
||||
{
|
||||
title: '资讯',
|
||||
docs: 'https://docs.rsshub.app/routes/game#you-xi-ji-yin',
|
||||
source: ['/news'],
|
||||
target: '/gamegene/news',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/news', require('./news'));
|
||||
};
|
||||
Reference in New Issue
Block a user