mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 22:19:40 +08:00
feat: add route for hpoi user activity (#4190)
This commit is contained in:
@@ -139,6 +139,16 @@ pageClass: routes
|
|||||||
|
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
### 用户动态
|
||||||
|
|
||||||
|
<Route author="luyuhuang" path="/hpoi/user/:user_id/:caty" example="/hpoi/user/116297/buy" :paramsDesc="['用户ID', '类别, 见下表']">
|
||||||
|
|
||||||
|
| 想买的手办 | 预定的手办 | 已入的手办 |
|
||||||
|
| ---------- | ---------- | ---------- |
|
||||||
|
| want | preorder | buy |
|
||||||
|
|
||||||
|
</Route>
|
||||||
|
|
||||||
## say 花火
|
## say 花火
|
||||||
|
|
||||||
### 文章
|
### 文章
|
||||||
|
|||||||
@@ -1507,6 +1507,7 @@ router.get('/guanchazhe/index/:type', require('./routes/guanchazhe/index'));
|
|||||||
// Hpoi 手办维基
|
// Hpoi 手办维基
|
||||||
router.get('/hpoi/info/:type?', require('./routes/hpoi/info'));
|
router.get('/hpoi/info/:type?', require('./routes/hpoi/info'));
|
||||||
router.get('/hpoi/:category/:words', require('./routes/hpoi'));
|
router.get('/hpoi/:category/:words', require('./routes/hpoi'));
|
||||||
|
router.get('/hpoi/user/:user_id/:caty', require('./routes/hpoi/user'));
|
||||||
|
|
||||||
// 通用CurseForge
|
// 通用CurseForge
|
||||||
router.get('/curseforge/:gameid/:catagoryid/:projectid/files', require('./routes/curseforge/generalfiles'));
|
router.get('/curseforge/:gameid/:catagoryid/:projectid/files', require('./routes/curseforge/generalfiles'));
|
||||||
|
|||||||
45
lib/routes/hpoi/user.js
Normal file
45
lib/routes/hpoi/user.js
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
|
||||||
|
const root_url = 'https://www.hpoi.net';
|
||||||
|
const caties = {
|
||||||
|
want: '想买的手办',
|
||||||
|
preorder: '预定的手办',
|
||||||
|
buy: '已入的手办',
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const { user_id, caty } = ctx.params;
|
||||||
|
let title = caties[caty];
|
||||||
|
if (!title) {
|
||||||
|
throw Error('Bad category. See <a href="https://docs.rsshub.app/anime.html#hpoi-shou-ban-wei-ji">https://docs.rsshub.app/anime.html#hpoi-shou-ban-wei-ji</a>');
|
||||||
|
}
|
||||||
|
|
||||||
|
const url = `${root_url}/user/${user_id}/hobby?order=actionDate&favState=${caty}&view=5&category=100&sortType=1`;
|
||||||
|
const response = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: url,
|
||||||
|
});
|
||||||
|
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
const list = $('#content > div.action-box div.action-detail')
|
||||||
|
.map((_, item) => {
|
||||||
|
item = $(item);
|
||||||
|
const img = item.find('div.list-5-left > a > img').attr('src');
|
||||||
|
const a = item.find('div.list-5-right > a.action-title');
|
||||||
|
return {
|
||||||
|
title: a.text(),
|
||||||
|
link: a.attr('href'),
|
||||||
|
description: `<img src="${img}"><p>${a.text()}</p>`,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.get();
|
||||||
|
|
||||||
|
title = $('div.col-md-15.col-sm-15 > div:nth-child(2)').text() + title;
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: title,
|
||||||
|
link: url,
|
||||||
|
item: list,
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user