@@ -2309,6 +2309,10 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的
|
||||
|
||||
<route name="Steam news" author="maple3142" example="/steam/news/282800" path="/steam/news/:appids" :paramsDesc="['游戏 id']"/>
|
||||
|
||||
### 小黑盒
|
||||
|
||||
<route name="用户动态" author="LogicJake" example="/xiaoheihe/user/7775687" path="xiaoheihe/user/:id" :paramsDesc="['用户 id']"/>
|
||||
|
||||
## 小说·文学·阅读
|
||||
|
||||
### 观止(每日一文)
|
||||
|
||||
@@ -1001,4 +1001,7 @@ router.get('/duozhuayu/search/:wd', require('./routes/duozhuayu/search'));
|
||||
// 创业邦
|
||||
router.get('/cyzone/author/:id', require('./routes/cyzone/author'));
|
||||
|
||||
// 小黑盒
|
||||
router.get('/xiaoheihe/user/:id', require('./routes/xiaoheihe/user'));
|
||||
|
||||
module.exports = router;
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
const axios = require('../../utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id;
|
||||
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: `https://api.xiaoheihe.cn/bbs/web/profile/post/links?userid=${id}&limit=10&offset=0&version=999.0.0`,
|
||||
});
|
||||
const user_data = response.data.user;
|
||||
const post_data = response.data.post_links;
|
||||
const user_name = user_data.username;
|
||||
|
||||
const out = await Promise.all(
|
||||
post_data.map(async (post) => {
|
||||
const title = post.description;
|
||||
const date = post.create_at;
|
||||
const itemUrl = `https://xiaoheihe.cn/community/7216/list/${post.linkid}`;
|
||||
|
||||
const response = await axios.get(itemUrl);
|
||||
const $ = cheerio.load(response.data);
|
||||
const description = $('.post-content').html();
|
||||
|
||||
const single = {
|
||||
title: title,
|
||||
link: itemUrl,
|
||||
description: description,
|
||||
pubDate: new Date(date * 1000).toUTCString(),
|
||||
};
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${user_name}的动态`,
|
||||
link: `https://xiaoheihe.cn/community/user/${id}/post_list`,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user