mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat(route): add 游戏年轮分类 (#7379)
This commit is contained in:
@@ -604,6 +604,18 @@ Example:`https://www.iyingdi.com/tz/people/55547` ,id 是 `55547`
|
||||
| 1 | 2 | 3 | 4 |
|
||||
</Route>
|
||||
|
||||
## 游戏年轮
|
||||
|
||||
### 分类
|
||||
|
||||
<Route author="nczitzk" example="/bibgame/sgame" path="/bibgame/:category?/:type?" :paramsDesc="['分类,见下表,默认为PC游戏', '类型,可在各分类页中导航栏中找到']">
|
||||
|
||||
| PC 游戏 | PS4 游戏 | Switch 游戏 | NS 其他板块 | galgame | VR 游戏 | 3DS 游戏 | psv 游戏 | xbox360 游戏 | ps3 游戏 | 其他掌机 |
|
||||
| ------- | -------- | ----------- | ----------- | ------- | ------- | -------- | -------- | ------------ | -------- | -------- |
|
||||
| pcgame | ps4 | sgame | nsaita | ps | bt | 3ds | psv | jiaocheng | ps3yx | zhangji |
|
||||
|
||||
</Route>
|
||||
|
||||
## 游戏时光
|
||||
|
||||
### 游戏时光新闻
|
||||
|
||||
@@ -4100,4 +4100,7 @@ router.get('/or/:id?', require('./routes/or'));
|
||||
// 海南大学
|
||||
router.get('/hainanu/ssszs', require('./routes/hainanu/ssszs'));
|
||||
|
||||
// 游戏年轮
|
||||
router.get('/bibgame/:category?/:type?', require('./routes/bibgame/category'));
|
||||
|
||||
module.exports = router;
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category || 'pcgame';
|
||||
const type = ctx.params.type || '';
|
||||
|
||||
const rootUrl = 'https://www.bibgame.com';
|
||||
const currentUrl = `${rootUrl}/${category}/${type}`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('.info_box a')
|
||||
.slice(0, 15)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
const link = item.attr('href');
|
||||
|
||||
return {
|
||||
title: item.text(),
|
||||
link: link.indexOf('http') > -1 ? link : `${rootUrl}${link}`,
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map(
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
content('#comment').parent().remove();
|
||||
|
||||
item.description = content('.abstract').html();
|
||||
item.pubDate = timezone(new Date(content('.time_box').text().trim()), +8);
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user