add zongheng.com (#1200)

close #439
This commit is contained in:
Georeth Chow
2018-11-27 14:36:41 +08:00
committed by DIYgod
parent 8b842c2f67
commit 9231dabc74
3 changed files with 40 additions and 0 deletions

View File

@@ -2047,6 +2047,10 @@ IATA 国际航空运输协会机场代码, 参见[维基百科 国际航空运
<route name="讨论区" author="Chingyat" example="/qidian/forum/1010400217" path="/qidian/forum/:id" :paramsDesc="['小说 id, 可在对应小说页 URL 中找到']"/> <route name="讨论区" author="Chingyat" example="/qidian/forum/1010400217" path="/qidian/forum/:id" :paramsDesc="['小说 id, 可在对应小说页 URL 中找到']"/>
### 纵横
<route name="章节" author="georeth" example="/zongheng/chapter/672340" path="/zongheng/chapter/:id" :paramsDesc="['小说 id, 可在对应小说页 URL 中找到']"/>
### 刺猬猫 ### 刺猬猫
<route name="章节" author="Netrvin" example="/ciweimao/chapter/100045750" path="/ciweimao/chapter/:id" :paramsDesc="['小说 id, 可在对应小说页 URL 中找到']"/> <route name="章节" author="Netrvin" example="/ciweimao/chapter/100045750" path="/ciweimao/chapter/:id" :paramsDesc="['小说 id, 可在对应小说页 URL 中找到']"/>

View File

@@ -409,6 +409,9 @@ router.get('/keep/user/:id', require('./routes/keep/user'));
router.get('/qidian/chapter/:id', require('./routes/qidian/chapter')); router.get('/qidian/chapter/:id', require('./routes/qidian/chapter'));
router.get('/qidian/forum/:id', require('./routes/qidian/forum')); router.get('/qidian/forum/:id', require('./routes/qidian/forum'));
// 纵横
router.get('/zongheng/chapter/:id', require('./routes/zongheng/chapter'));
// 刺猬猫 // 刺猬猫
router.get('/ciweimao/chapter/:id', require('./routes/ciweimao/chapter')); router.get('/ciweimao/chapter/:id', require('./routes/ciweimao/chapter'));

View File

@@ -0,0 +1,33 @@
const axios = require('../../utils/axios');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const id = ctx.params.id;
const [$, $home] = (await Promise.all([axios.get(`http://book.zongheng.com/showchapter/${id}.html`), axios.get(`http://book.zongheng.com/book/${id}.html`)])).map((res) => cheerio.load(res.data));
const date_re = /更新时间:(.*)$/;
const cover_url = $home('.book-img img').attr('src');
const description = $home('.book-dec').text();
const name = $('.book-meta h1').text();
const chapters = $('.volume-list li a');
const items = [];
for (let i = 0; i < chapters.length; i++) {
const chapter = chapters.eq(i);
const date_string = date_re.exec(chapter.attr('title'))[1];
items.push({
title: chapter.text(),
pubDate: new Date(date_string).toUTCString(),
link: chapter.attr('href'),
});
}
ctx.state.data = {
title: `纵横 ${name}`,
link: `http://book.zongheng.com/book/${id}.html`,
description,
image: cover_url,
item: items,
};
};