mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 22:19:40 +08:00
feat: add zhaishuyuan (#4368)
Co-authored-by: DIYgod <diy.d.god@gmail.com>
This commit is contained in:
@@ -1549,6 +1549,17 @@
|
||||
},
|
||||
],
|
||||
},
|
||||
'zhaishuyuan.com': {
|
||||
_name: '斋书苑',
|
||||
www: [
|
||||
{
|
||||
title: '最新章节',
|
||||
docs: 'https://docs.rsshub.app/reading.html#zhai-shu-yuan',
|
||||
source: ['/book/:id', '/read/:id'],
|
||||
target: '/novel/zhaishuyuan/:id',
|
||||
},
|
||||
],
|
||||
},
|
||||
'hbut.edu.cn': {
|
||||
_name: '湖北工业大学',
|
||||
www: [
|
||||
|
||||
@@ -203,6 +203,16 @@ count 的取值范围为 1-12,为防止请求次数过多,推荐设置为 5
|
||||
|
||||
<Route author="LogicJake" example="/p-articles/contributors/朗天" path="/p-articles/contributors/:author" :paramsDesc="['作者 id, 可在作者页面 URL 找到']"/>
|
||||
|
||||
## 斋书苑
|
||||
|
||||
### 最新章节
|
||||
|
||||
<Route author="suiyuran" example="/novel/zhaishuyuan/17858" path="/novel/zhaishuyuan/:id" :paramsDesc="['小说 id, 可在对应小说页 URL 中找到, 例如 `17858`']" radar="1">
|
||||
|
||||
举例网址:https://www.zhaishuyuan.com/book/17858
|
||||
|
||||
</Route>
|
||||
|
||||
## 纵横
|
||||
|
||||
### 章节
|
||||
|
||||
@@ -522,6 +522,7 @@ router.get('/novel/wenxuemi/:id1/:id2', require('./routes/novel/wenxuemi'));
|
||||
router.get('/novel/booksky/:id', require('./routes/novel/booksky'));
|
||||
router.get('/novel/shuquge/:id', require('./routes/novel/shuquge'));
|
||||
router.get('/novel/ptwxz/:id1/:id2', require('./routes/novel/ptwxz'));
|
||||
router.get('/novel/zhaishuyuan/:id', require('./routes/novel/zhaishuyuan'));
|
||||
|
||||
// 中国气象网
|
||||
router.get('/weatheralarm', require('./routes/weatheralarm'));
|
||||
|
||||
42
lib/routes/novel/zhaishuyuan.js
Normal file
42
lib/routes/novel/zhaishuyuan.js
Normal file
@@ -0,0 +1,42 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const iconv = require('iconv-lite');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id;
|
||||
const url = 'https://www.zhaishuyuan.com';
|
||||
const link = `${url}/book/${id}`;
|
||||
let extendedGot = got.extend({ headers: { Referer: url }, responseType: 'buffer' });
|
||||
const response = await extendedGot.get(link);
|
||||
const html = iconv.decode(response.data, 'gb2312');
|
||||
const $ = cheerio.load(html);
|
||||
const title = $('.booktitle > h1').text();
|
||||
const description = $('#bookintro > p').text();
|
||||
const image = $('#bookimg > img').attr('src');
|
||||
const list = $('#newlist > ul > li')
|
||||
.find('a')
|
||||
.map((_, { attribs: { title, href } }) => ({ title, link: `${url}${href}` }))
|
||||
.get();
|
||||
extendedGot = got.extend({ headers: { Referer: link }, responseType: 'buffer' });
|
||||
const item = await Promise.all(
|
||||
list.map(
|
||||
async ({ title, link }) =>
|
||||
await ctx.cache.tryGet(link, async () => {
|
||||
const response = await extendedGot.get(link);
|
||||
const html = iconv.decode(response.data, 'gb2312');
|
||||
const $ = cheerio.load(html);
|
||||
const content = $('#content');
|
||||
content.find('div').remove();
|
||||
const description = content.html();
|
||||
const spanList = $('.title > span');
|
||||
const author = spanList
|
||||
.eq(0)
|
||||
.find('a')
|
||||
.text();
|
||||
const pubDate = spanList.eq(2).text();
|
||||
return { title, link, description, author, pubDate };
|
||||
})
|
||||
)
|
||||
);
|
||||
ctx.state.data = { title, link, description, image, item };
|
||||
};
|
||||
Reference in New Issue
Block a user