diff --git a/docs/reading.md b/docs/reading.md index 4c6076630b..436ecb08af 100644 --- a/docs/reading.md +++ b/docs/reading.md @@ -32,6 +32,12 @@ pageClass: routes +## 爱下电子书 + +### 最新章节 + + + ## 笔趣阁 ### 小说更新 diff --git a/lib/router.js b/lib/router.js index b71e26596b..2698ea5fbd 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2208,6 +2208,9 @@ router.get('/ifeng/feng/:id/:type', require('./routes/ifeng/feng')); router.get('/open163/vip', require('./routes/netease/open/vip')); router.get('/open163/latest', require('./routes/netease/open/latest')); +// 爱下电子书 +router.get('/axdzs/:id1/:id2', require('./routes/novel/axdzs')); + // HackerOne router.get('/hackerone/hacktivity', require('./routes/hackerone/hacktivity')); diff --git a/lib/routes/novel/axdzs.js b/lib/routes/novel/axdzs.js new file mode 100644 index 0000000000..3c284fb162 --- /dev/null +++ b/lib/routes/novel/axdzs.js @@ -0,0 +1,42 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +const baseUrl = 'https://read.aixdzs.com/'; + +module.exports = async (ctx) => { + const id1 = ctx.params.id1; + const id2 = ctx.params.id2; + const novelUrl = `${baseUrl}${id1}/${id2}/`; + const response = await got({ + method: 'get', + url: novelUrl, + }); + + const data = response.data; + const $ = cheerio.load(data); + + const title = $('h1').text(); + const description = $('meta[name="description"]').attr('content'); + const lastChapter = $('.chapter') + .last() + .children(); + const chapterUrl = novelUrl + lastChapter.attr('href'); + const chapterTitle = lastChapter.text(); + const chapterContent = await ctx.cache.tryGet(chapterUrl, async () => { + const lastChapter = await got.get(chapterUrl); + const $ = cheerio.load(lastChapter.data); + return $('.content').html(); + }); + ctx.state.data = { + title: `爱下电子书-${title}`, + description: description, + link: novelUrl, + item: [ + { + title: chapterTitle, + link: chapterUrl, + description: chapterContent, + }, + ], + }; +};