mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-05 12:21:31 +08:00
feat: optimize hpoi user
This commit is contained in:
@@ -141,11 +141,11 @@ pageClass: routes
|
||||
|
||||
### 用户动态
|
||||
|
||||
<Route author="luyuhuang" path="/hpoi/user/:user_id/:caty" example="/hpoi/user/116297/buy" :paramsDesc="['用户ID', '类别, 见下表']">
|
||||
<Route author="luyuhuang DIYgod" path="/hpoi/user/:user_id/:caty" example="/hpoi/user/116297/buy" :paramsDesc="['用户ID', '类别, 见下表']">
|
||||
|
||||
| 想买的手办 | 预定的手办 | 已入的手办 |
|
||||
| ---------- | ---------- | ---------- |
|
||||
| want | preorder | buy |
|
||||
| 想买 | 预定 | 已入 | 关注 | 有过 |
|
||||
| ---- | -------- | ---- | ---- | ------ |
|
||||
| want | preorder | buy | care | resell |
|
||||
|
||||
</Route>
|
||||
|
||||
|
||||
@@ -2,20 +2,11 @@ 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 url = `${root_url}/user/${user_id}/hobby?order=actionDate&favState=${caty}&view=5&category=100&sortType=2`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: url,
|
||||
@@ -29,13 +20,24 @@ module.exports = async (ctx) => {
|
||||
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>`,
|
||||
link: 'https://www.hpoi.net/' + a.attr('href'),
|
||||
description: `<img src="${img}"><br>制作:${item
|
||||
.find('.badge')
|
||||
.eq(0)
|
||||
.text()}<br>发售:${item
|
||||
.find('.badge')
|
||||
.eq(1)
|
||||
.text()}`,
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
title = $('div.col-md-15.col-sm-15 > div:nth-child(2)').text() + title;
|
||||
const title =
|
||||
$('div.col-md-15.col-sm-15 > div:nth-child(2)').text() +
|
||||
$('.navbar-nav .active')
|
||||
.eq(0)
|
||||
.text() +
|
||||
'的手办';
|
||||
|
||||
ctx.state.data = {
|
||||
title: title,
|
||||
|
||||
Reference in New Issue
Block a user