update docs for biquge

This commit is contained in:
DIYgod 2018-05-06 14:23:26 +08:00
parent acf344033a
commit e878da962a
No known key found for this signature in database
GPG Key ID: EC0B76A252D3EF67
3 changed files with 19 additions and 9 deletions

View File

@ -461,4 +461,14 @@ city: 城市的中文名,可选,默认北京
project: 产品ID
key: 产品密钥
key: 产品密钥
## 笔趣阁
### 小说章节
举例: https://rss.now.sh/biquge/novel/latestchapter/52_52542
路由: `/biquge/novel/latestchapter/:id`
参数: id小说 id可在对应小说页 URL 中找到

View File

@ -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}`,

View File

@ -19,7 +19,7 @@
{{ each item }}
<item>
<title><![CDATA[{{ $value.title }}]]></title>
<description><![CDATA[{{@ $value.description }}]]></description>
<description><![CDATA[{{@ $value.description || $value.title }}]]></description>
{{ if $value.pubDate }}<pubDate>{{ $value.pubDate }}</pubDate>{{ /if }}
<guid>{{ $value.link }}</guid>
<link>{{ $value.link }}</link>