feat: add MM范 (#5754)

Co-authored-by: Henry Wang <hi@henry.wang>
This commit is contained in:
Ethan Shen 2020-10-05 21:57:09 +08:00 committed by GitHub
parent c60eb7e052
commit f777e653e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 117 additions and 0 deletions

View File

@ -117,6 +117,31 @@ pageClass: routes
<Route author="hoilc" example="/loveheaven/update/kimetsu-no-yaiba" path="/loveheaven/update/:slug" :paramsDesc="['漫画 slug可在漫画页面URL中找到不包括开头的`manga-`,也不包括末尾的`.html`']" />
## MM 范
### 分类
<Route author="nczitzk" example="/95mm/tab/热门" path="/95mm/tab/:tab?" :paramsDesc="['分类,见下表,默认为最新']">
| 最新 | 热门 | 校花 | 森系 | 清纯 | 童颜 | 嫩模 | 少女 |
| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- |
</Route>
### 标签
<Route author="nczitzk" example="/95mm/tag/黑丝" path="/95mm/tag/:tag" :paramsDesc="['标签,可在对应标签页中找到']"/>
### 集合
<Route author="nczitzk" example="/95mm/category/1" path="/95mm/category/:category" :paramsDesc="['集合,见下表']">
| 清纯唯美 | 摄影私房 | 明星写真 | 三次元 | 异域美景 | 性感妖姬 | 游戏主题 | 美女壁纸 |
| -------- | -------- | -------- | ------ | -------- | -------- | -------- | -------- |
| 1 | 2 | 4 | 5 | 6 | 7 | 9 | 11 |
</Route>
## NASA 每日天文图片
### NASA

View File

@ -3257,8 +3257,14 @@ router.get('/appsales/:caty?/:time?', require('./routes/appsales/index'));
// CGTN
router.get('/cgtn/top', require('./routes/cgtn/top'));
// MM范
router.get('/95mm/tab/:tab?', require('./routes/95mm/tab'));
router.get('/95mm/tag/:tag', require('./routes/95mm/tag'));
router.get('/95mm/category/:category', require('./routes/95mm/category'));
// 中国工程科技知识中心
router.get('/cktest/app/:ctgroup?/:domain?', require('./routes/cktest/app'));
// 妈咪帮
router.get('/mamibuy/:caty?/:age?/:sort?', require('./routes/mamibuy/index'));

View File

@ -0,0 +1,18 @@
const utils = require('./utils');
module.exports = async (ctx) => {
const categories = {
1: '清纯唯美',
2: '摄影私房',
4: '明星写真',
5: '三次元',
6: '异域美景',
7: '性感妖姬',
9: '游戏主题',
11: '美女壁纸',
};
const rootUrl = `https://www.95mm.net/category-${ctx.params.category}/list-1/index.html?page=1`;
ctx.state.data = await utils(ctx, categories[ctx.params.category], rootUrl);
};

9
lib/routes/95mm/tab.js Normal file
View File

@ -0,0 +1,9 @@
const utils = require('./utils');
module.exports = async (ctx) => {
ctx.params.tab = ctx.params.tab || '最新';
const rootUrl = `https://www.95mm.net/home-ajax/index.html?tabcid=${ctx.params.tab}&page=1`;
ctx.state.data = await utils(ctx, ctx.params.tab, rootUrl);
};

7
lib/routes/95mm/tag.js Normal file
View File

@ -0,0 +1,7 @@
const utils = require('./utils');
module.exports = async (ctx) => {
const rootUrl = `https://www.95mm.net/tag-${ctx.params.tag}/page-1/index.html`;
ctx.state.data = await utils(ctx, ctx.params.tag, rootUrl);
};

52
lib/routes/95mm/utils.js Normal file
View File

@ -0,0 +1,52 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx, title, rootUrl) => {
const response = await got({
method: 'get',
url: rootUrl,
header: {
Referer: 'https://www.95mm.net',
},
});
const $ = cheerio.load(response.data);
const list = $('div.list-body')
.map((_, item) => {
item = $(item);
const a = item.find('a');
return {
title: a.text(),
link: a.attr('href'),
};
})
.get();
const items = await Promise.all(
list.map(
async (item) =>
await ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
});
const images = detailResponse.data.match(/src": '(.*?)',"width/g);
item.description = '';
for (const i of images) {
item.description += `<img src="${i.split("'")[1]}">`;
}
return item;
})
)
);
return {
title: `${title} - MM范`,
link: rootUrl,
item: items,
};
};