From e878da962a7589bdaeaefc49fe07ed1474adf4be Mon Sep 17 00:00:00 2001 From: DIYgod Date: Sun, 6 May 2018 14:23:26 +0800 Subject: [PATCH] update docs for biquge --- docs/README.md | 12 +++++++++++- routes/biquge/chapter.js | 14 +++++++------- views/rss.art | 2 +- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/docs/README.md b/docs/README.md index c8f146cc4..c6d1f899e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -461,4 +461,14 @@ city: 城市的中文名,可选,默认北京 project: 产品ID -key: 产品密钥 \ No newline at end of file +key: 产品密钥 + +## 笔趣阁 + +### 小说章节 + +举例: https://rss.now.sh/biquge/novel/latestchapter/52_52542 + +路由: `/biquge/novel/latestchapter/:id` + +参数: id,小说 id,可在对应小说页 URL 中找到 \ No newline at end of file diff --git a/routes/biquge/chapter.js b/routes/biquge/chapter.js index 91571790b..0d45c436b 100644 --- a/routes/biquge/chapter.js +++ b/routes/biquge/chapter.js @@ -6,9 +6,9 @@ const config = require('../../config'); const iconv = require('iconv-lite'); const baseUrl = 'https://www.biquge5200.com/'; -//获取小说的最新章节列表 +// 获取小说的最新章节列表 module.exports = async (ctx) => { - const id = ctx.params.id; //小说id + const id = ctx.params.id; // 小说id const response = await axios({ method: 'get', @@ -21,22 +21,22 @@ module.exports = async (ctx) => { // responseEncoding: 'gbk', //该配置项在 0.18版本中没有打包进去 responseType: 'arraybuffer' }); - const responseHtml = iconv.decode(response.data, 'GBK');; + const responseHtml = iconv.decode(response.data, 'GBK'); // console.log('responseHtml',responseHtml); - let $ = cheerio.load(responseHtml); + const $ = cheerio.load(responseHtml); const title = $('#list>dl>dt>b').eq(0).text(); const description = $('#intro>p').eq(0).text(); const cover_url = $('#fmimg>img').eq(0).attr('src'); const list = $('dd', '#list>dl').slice(0, 9); - let chapter_item = []; + const chapter_item = []; for (let i = 0; i < list.length; i++) { const el = $(list[i]).find('a').eq(0); const item = { title: el.text(), link: el.attr('href') }; - chapter_item.push(item) - }; + chapter_item.push(item); + } // console.log('chapter_item',chapter_item) ctx.body = art(path.resolve(__dirname, '../../views/rss.art'), { title: `笔趣阁 ${title}`, diff --git a/views/rss.art b/views/rss.art index 28cbc5a67..375284955 100644 --- a/views/rss.art +++ b/views/rss.art @@ -19,7 +19,7 @@ {{ each item }} <![CDATA[{{ $value.title }}]]> - + {{ if $value.pubDate }}{{ $value.pubDate }}{{ /if }} {{ $value.link }} {{ $value.link }}