mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 05:59:00 +08:00
feat: add vgtime keyword, close #2328
This commit is contained in:
@@ -199,11 +199,15 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的
|
||||
|
||||
### 游戏时光新闻
|
||||
|
||||
<Route author="MyFaith" example="/vgtime/news" path="vgtime/news"/>
|
||||
<Route author="MyFaith" example="/vgtime/news" path="/vgtime/news"/>
|
||||
|
||||
### 游戏时光游戏发售表
|
||||
|
||||
<Route author="MyFaith" example="/vgtime/release" path="vgtime/release"/>
|
||||
<Route author="MyFaith" example="/vgtime/release" path="/vgtime/release"/>
|
||||
|
||||
### 关键词资讯
|
||||
|
||||
<Route author="DIYgod" example="/vgtime/keyword/怪物猎人" path="/vgtime/keyword/:keyword"/>
|
||||
|
||||
## 游研社
|
||||
|
||||
|
||||
@@ -40,6 +40,9 @@ sidebar: auto
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: `https://api.bilibili.com/x/space/coin/video?vmid=${uid}&jsonp=jsonp`,
|
||||
headers: {
|
||||
Referer: `https://space.bilibili.com/${uid}/`,
|
||||
},
|
||||
});
|
||||
|
||||
const data = response.data.data; // response.data 为 HTTP GET 请求返回的数据对象
|
||||
|
||||
@@ -1144,6 +1144,7 @@ router.get('/tophub/:id', require('./routes/tophub'));
|
||||
// 游戏时光
|
||||
router.get('/vgtime/news', require('./routes/vgtime/news.js'));
|
||||
router.get('/vgtime/release', require('./routes/vgtime/release'));
|
||||
router.get('/vgtime/keyword/:keyword', require('./routes/vgtime/keyword'));
|
||||
|
||||
// MP4吧
|
||||
router.get('/mp4ba/:param', require('./routes/mp4ba'));
|
||||
|
||||
46
lib/routes/vgtime/keyword.js
Normal file
46
lib/routes/vgtime/keyword.js
Normal file
@@ -0,0 +1,46 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { keyword = '' } = ctx.params;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: `http://www.vgtime.com/search/load.jhtml?keyword=${encodeURIComponent(keyword)}&type=topic&typeTag=2&page=1&pageSize=12`,
|
||||
headers: {
|
||||
Referer: `http://www.vgtime.com/search/list.jhtml?keyword=${encodeURIComponent(keyword)}`,
|
||||
},
|
||||
});
|
||||
const data = response.data.data;
|
||||
|
||||
const result = await Promise.all(
|
||||
data.map(async (item) => {
|
||||
const url = `https://www.vgtime.com/topic/${item.objectId}.jhtml`;
|
||||
|
||||
const description = await ctx.cache.tryGet(url, async () => {
|
||||
const result = await got.get(url);
|
||||
|
||||
const $ = cheerio.load(result.data);
|
||||
$('h1.art_tit').remove();
|
||||
$('.editor_name').remove();
|
||||
|
||||
return $('.vg_main article').html();
|
||||
});
|
||||
|
||||
const result = {
|
||||
title: item.title,
|
||||
author: JSON.parse(item.content).userName,
|
||||
pubDate: new Date(item.createTime * 1000).toUTCString(),
|
||||
link: url,
|
||||
description,
|
||||
};
|
||||
|
||||
return Promise.resolve(result);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `游戏时光${keyword}资讯`,
|
||||
link: `http://www.vgtime.com/search/list.jhtml?keyword=${encodeURIComponent(keyword)}`,
|
||||
item: result,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user