mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 23:00:48 +08:00
feat: add route for hpoi user activity (#4190)
This commit is contained in:
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