feat: add route 漫小肆 (#5207)

Co-authored-by: junfeng <junfeng_pan96@qq.com>
This commit is contained in:
junfengP
2020-07-28 16:10:34 +01:00
committed by GitHub
co-authored by junfeng
parent eddba23099
commit 35f3889f40
4 changed files with 65 additions and 0 deletions
+11
View File
@@ -2095,4 +2095,15 @@
},
],
},
'manxiaosi.com': {
_name: '漫小肆',
'.': [
{
title: '漫画更新',
docs: 'https://docs.rsshub.app/anime.html#man-xiao-si',
source: '/book/:id',
target: '/manxiaosi/book/:id',
}
],
},
});
+6
View File
@@ -337,3 +337,9 @@ pageClass: routes
### 最新汉化
<Route author="junfengP" example="/zdfx" path="/zdfx"/>
## 漫小肆
### 漫画更新
<Route author="junfengP" path="/manxiaosi/book/:id" example="/manxiaosi/book/90" :paramsDesc="['漫画id,漫画主页的地址栏中']" radar="1"/>
+6
View File
@@ -2956,4 +2956,10 @@ router.get('/ngbj/cat/:cat', require('./routes/niaogebiji/cat'));
// 东方我乐多丛志
router.get('/touhougarakuta/:language/:type', require('./routes/touhougarakuta'));
// 漫小肆
router.get('/manxiaosi/book/:id', require('./routes/manxiaosi/book'));
// 吉林大学校内通知
router.get('/jlu/oa', require('./routes/universities/jlu/oa'));
module.exports = router;
+42
View File
@@ -0,0 +1,42 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const host = 'http://www.manxiaosi.com';
const ua = 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Mobile Safari/537.36';
module.exports = async (ctx) => {
const id = ctx.params.id;
const url = host + `/book/${id}`;
const response = await got.get(url);
const $ = cheerio.load(response.data);
const list = $('#detail-list-select > li > a').reverse().slice(0, 10).get();
const items = await Promise.all(
list.map(async (item) => {
item = $(item);
const itemLink = host + item.attr('href');
const simple = {
title: item.text(),
link: itemLink,
};
const details = await ctx.cache.tryGet(itemLink, async () => {
// 具体页面限制手机UA
const response = await got.get(itemLink, {
headers: {
'user-agent': ua,
},
});
const $ = cheerio.load(response.body);
return {
description: $('div#cp_img').html(),
};
});
return Promise.resolve(Object.assign({}, simple, details));
})
);
ctx.state.data = {
title: '漫小肆 ' + $('div.info > h1').text(),
link: url,
description: '漫小肆 ' + $('div.info > h1').text(),
item: items,
};
};