feat(route): add 欢乐书客 (#14591)
* feat(route): add 欢乐书客 * update radar * rm redundant code
This commit is contained in:
parent
09cf6dbdd2
commit
e41ed0c48a
|
|
@ -0,0 +1,46 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { id } = ctx.params;
|
||||
const limit = Number.parseInt(ctx.query.limit) || 10;
|
||||
|
||||
const baseUrl = 'https://www.hbooker.com';
|
||||
|
||||
const { data: response } = await got(`${baseUrl}/book/${id}?arr_reverse=1`);
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
const list = $('div.book-chapter-list ul li a')
|
||||
.slice(0, limit)
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.text(),
|
||||
link: item.attr('href'),
|
||||
};
|
||||
});
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const { data: response } = await got(item.link);
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
const rawDate = $('div.read-hd p span').eq(2).text();
|
||||
item.pubDate = timezone(parseDate(rawDate.replace('更新时间:', '')), +8);
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `欢乐书客 ${$('div.book-title h1').text()}`,
|
||||
link: `${baseUrl}/book/${id}`,
|
||||
description: $('div.book-desc').text(),
|
||||
image: $('div.book-cover img').attr('src'),
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/chapter/:id': ['keocheung'],
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'hbooker.com': {
|
||||
_name: '欢乐书客',
|
||||
'.': [
|
||||
{
|
||||
title: '章节',
|
||||
docs: 'https://docs.rsshub.app/routes/reading#huan-le-shu-ke',
|
||||
source: '/book/:id',
|
||||
target: '/hbooker/chapter/:id',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = (router) => {
|
||||
router.get('/chapter/:id', require('./chapter'));
|
||||
};
|
||||
|
|
@ -248,6 +248,12 @@
|
|||
|
||||
<Route author="junbaor" example="/enclavebooks/collection/103702" path="/enclavebooks/collection/:uid" paramsDesc={['用户ID, 自行抓包寻找']} />
|
||||
|
||||
## 欢乐书客 {#huan-le-shu-ke}
|
||||
|
||||
### 章节 {#huan-le-shu-ke-zhang-jie}
|
||||
|
||||
<Route author="keocheung" example="/hbooker/chapter/100113279" path="/hbooker/chapter/:id" paramsDesc={['小说 id, 可在对应小说页 URL 中找到']} radar="1" />
|
||||
|
||||
## 晋江文学城 {#jin-jiang-wen-xue-cheng}
|
||||
|
||||
### 作者最新作品 {#jin-jiang-wen-xue-cheng-zuo-zhe-zui-xin-zuo-pin}
|
||||
|
|
|
|||
Loading…
Reference in New Issue