parent
bf3fa86c50
commit
4a482f54ca
|
|
@ -557,6 +557,10 @@ RSSHub 提供下列 API 接口:
|
|||
|
||||
</route>
|
||||
|
||||
### NGA
|
||||
|
||||
<route name="论坛" author="xyqfer" example="/nga/forum/485" path="/nga/forum/:fid" :paramsDesc="['分区 id, 可在分区主页 URL 找到']"/>
|
||||
|
||||
## 编程
|
||||
|
||||
### 掘金
|
||||
|
|
|
|||
|
|
@ -833,4 +833,7 @@ router.get('/testerhome/newest', require('./routes/testerhome/newest'));
|
|||
router.get('/weseepro/newest', require('./routes/weseepro/newest'));
|
||||
router.get('/weseepro/circle', require('./routes/weseepro/circle'));
|
||||
|
||||
// NGA
|
||||
router.get('/nga/forum/:fid', require('./routes/nga/forum'));
|
||||
|
||||
module.exports = router;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,60 @@
|
|||
const axios = require('../../utils/axios');
|
||||
const qs = require('querystring');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { fid } = ctx.params;
|
||||
const axiosInstance = axios.create({
|
||||
baseURL: 'https://ngabbs.com/app_api.php',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'X-User-Agent': 'NGA_skull/6.0.5(iPhone10,3;iOS 12.0.1)',
|
||||
},
|
||||
});
|
||||
const homePage = await axiosInstance.request({
|
||||
method: 'post',
|
||||
url: '?__lib=subject&__act=list',
|
||||
data: qs.stringify({
|
||||
fid,
|
||||
}),
|
||||
});
|
||||
|
||||
const list = homePage.data.result.data.filter(({ tid }) => tid);
|
||||
|
||||
const resultItem = await Promise.all(
|
||||
list.map(async ({ subject, postdate, tid }) => {
|
||||
const link = `https://nga.178.com/read.php?tid=${tid}`;
|
||||
const item = {
|
||||
title: subject,
|
||||
description: '',
|
||||
link,
|
||||
pubDate: new Date(postdate * 1000).toUTCString(),
|
||||
};
|
||||
|
||||
const description = await ctx.cache.tryGet(
|
||||
`nga-forum: ${link}`,
|
||||
async () => {
|
||||
const response = await axiosInstance.request({
|
||||
method: 'post',
|
||||
url: '?__lib=post&__act=list',
|
||||
data: qs.stringify({
|
||||
tid,
|
||||
}),
|
||||
});
|
||||
|
||||
return response.data.result[0].content;
|
||||
},
|
||||
24 * 60 * 60
|
||||
);
|
||||
|
||||
item.description = description;
|
||||
return Promise.resolve(item);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `NGA-${fid}`,
|
||||
link: `https://nga.178.com/thread.php?fid=${fid}`,
|
||||
description: 'NGA是国内专业的游戏玩家社区,魔兽世界,英雄联盟,炉石传说,风暴英雄,暗黑破坏神3(D3)游戏攻略讨论,以及其他热门游戏玩家社区',
|
||||
item: resultItem,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue