rss:add uukanshu.com (#258)

* add uukansu rss
This commit is contained in:
bot_3310 2018-06-03 00:33:47 +08:00 committed by DIYgod
parent 09a616d2b8
commit fb82a648a4
4 changed files with 56 additions and 0 deletions

View File

@ -129,6 +129,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
- Popular Recent Posts
- 纽约时报
- 新闻早报
- UU 看书
- 小说章节
## 鸣谢

View File

@ -1046,3 +1046,13 @@ language语言可在 [Trending 页](https://github.com/trending/javascript
路由: `/nytimes/morning_post`
参数: 无
## UU 看书
### 小说章节
举例: [https://rsshub.app/uukanshu/chapter/49621](https://rsshub.app/uukanshu/chapter/49621)
路由: `/uukanshu/chapter/:id`
参数: id小说 id可在对应小说页 URL 中找到

View File

@ -278,4 +278,7 @@ router.get('/yande.re/post/popular_recent/:period', require('./routes/yande.re/p
// nytimes
router.get('/nytimes/morning_post', require('./routes/nytimes/morning_post'));
// uukanshu
router.get('/uukanshu/chapter/:uid', require('./routes/uukanshu/chapter'));
module.exports = router;

View File

@ -0,0 +1,41 @@
const axios = require('../../utils/axios');
const cheerio = require('cheerio');
const config = require('../../config');
const iconv = require('iconv-lite');
module.exports = async (ctx) => {
const uid = ctx.params.uid;
const response = await axios({
method: 'post',
url: `https://www.uukanshu.com/b/${uid}`,
headers: {
'User-Agent': config.ua,
Referer: 'https://www.uukanshu.com/b/${uid}',
},
responseType: 'arraybuffer',
});
const data = iconv.decode(response.data, 'gb2312');
const $ = cheerio.load(data);
const name = $('.jieshao_content>h1>a').text();
const list = $('#chapterList li a');
const cover_url = $('.bookImg>img').attr('src');
const chapter_item = [];
for (let i = 0; i < list.length; i++) {
const el = $(list[i]);
const item = {
title: el.text(),
link: `https://www.uukanshu.com${el.attr('href')}`,
};
chapter_item.push(item);
}
ctx.state.data = {
title: `UU看书 ${name}`,
link: `https://www.uukanshu.com/b/${uid}`,
description: $('.jieshao_content h3').text(),
image: cover_url,
item: chapter_item,
};
};