feat(route): yxrb (#11542)
This commit is contained in:
parent
f7925551ec
commit
af1ebfb170
12
docs/game.md
12
docs/game.md
|
|
@ -855,6 +855,18 @@ Example:`https://www.iyingdi.com/tz/people/55547` ,id 是 `55547`
|
|||
|
||||
</Route>
|
||||
|
||||
## 游戏日报
|
||||
|
||||
### 分类
|
||||
|
||||
<Route author="TonyRL" example="/yxrb/info" path="/yxrb/:category?" :paramsDesc="['分类,见下表,预设为 `info`']" radar="1">
|
||||
|
||||
| 资讯 | 访谈 | 服务 | 游理游据 |
|
||||
| ---- | ------- | ------- | -------- |
|
||||
| info | talking | service | comments |
|
||||
|
||||
</Route>
|
||||
|
||||
## 游戏时光
|
||||
|
||||
### 游戏时光新闻
|
||||
|
|
|
|||
|
|
@ -0,0 +1,61 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
const baseUrl = 'http://news.yxrb.net';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { category = 'info' } = ctx.params;
|
||||
const link = `${baseUrl}/${category}/`;
|
||||
const response = await got(link);
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('.channel-news .item')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.find('.title a').attr('title'),
|
||||
link: `${baseUrl}${item.find('.title a').attr('href')}`,
|
||||
author: item.find('.author a').text().split('作者 : ')[1],
|
||||
};
|
||||
});
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const response = await got(item.link);
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
item.author = item.author ? item.author : $('.author-info .name a').text().split('作者 : ')[1];
|
||||
item.pubDate = timezone(
|
||||
parseDate(
|
||||
$('.publish-time')
|
||||
.first()
|
||||
.contents()
|
||||
.filter((_, e) => e.nodeType === 3)
|
||||
.text()
|
||||
.trim(),
|
||||
'YYYY-MM-DD HH:mm:ss'
|
||||
),
|
||||
8
|
||||
);
|
||||
item.description = $('article').html();
|
||||
item.category = $('.tags a')
|
||||
.toArray()
|
||||
.map((item) => $(item).text());
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('head title').text(),
|
||||
description: $('head meta[name=description]').attr('content'),
|
||||
link,
|
||||
image: $('.channel-img img').attr('src'),
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/:category?': ['TonyRL'],
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'yxrb.net': {
|
||||
_name: '游戏日报',
|
||||
news: [
|
||||
{
|
||||
title: '分类',
|
||||
docs: 'https://docs.rsshub.app/game.html#you-xi-ri-bao',
|
||||
source: ['/:category', '/'],
|
||||
target: '/yxrb/:category',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = (router) => {
|
||||
router.get('/:category?', require('./home'));
|
||||
};
|
||||
Loading…
Reference in New Issue