feat: add 酷18分站 & 禁忌书屋 (#6385)

This commit is contained in:
Ethan Shen
2020-12-09 22:32:31 +00:00
committed by GitHub
parent baaa141dcf
commit 61009b2efe
4 changed files with 114 additions and 2 deletions
+26
View File
@@ -332,6 +332,32 @@ R18 显示
| ------ | ---------- | ---------- |
| pic | top | top-4h |
## 酷 18
### 分站
<Route author="nczitzk" example="/cool18" path="/cool18/:id?" :paramsDesc="['分站,见下表,默认为禁忌书屋']">
| 性趣贴图 | 色色动漫 | 情色靓影 | 私房自拍 | 禁忌书屋 | 性趣论坛 | 情色无忌 | 成人影视 |
| -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |
| bbs | bbs7 | bbs2 | bbs6 | bbs4 | bj | bbs5 | bbs3 |
::: tip 提示
禁忌书屋文档参见 [此处](https://docs.rsshub.app/reading.html#jin-ji-shu-wu)
:::
</Route>
### 精华区
<Route author="nczitzk" example="/cool18/bbs/gold" path="/cool18/:id/gold" :paramsDesc="['分站,见上表,默认为禁忌书屋']"/>
### 搜索关键字
<Route author="nczitzk" example="/cool18/bbs/keywords/都市" path="/cool18/:id/keywords/:keyword?" :paramsDesc="['分站,见上表,默认为禁忌书屋', '关键字']"/>
### 妹子图
<Route author="kobemtl xyqfer" example="/jandan/ooxx" path="/jandan/:sub_model" :paramsDesc="['煎蛋板块名称']"/>
+27 -2
View File
@@ -63,6 +63,10 @@ pageClass: routes
</Route>
## 归档
<Route author="nczitzk" example="/sobooks/date/2020-11" path="/sobooks/date/:date?" :paramsDesc="['日期,见例子,默认为当前年月']"/>
## UU 看书
### 小说更新
@@ -192,9 +196,30 @@ count 的取值范围为 1-12,为防止请求次数过多,推荐设置为 5
## 观止(每日一文)
## 归档
<route name="观止" author="Andiedie" example="/guanzhi" path="/guanzhi"/>
<Route author="nczitzk" example="/sobooks/date/2020-11" path="/sobooks/date/:date?" :paramsDesc="['日期,见例子,默认为当前年月']"/>
## 禁忌书屋
### 首页
<Route author="nczitzk" example="/cool18/bbs4" path="/cool18/bbs4"/>
### 精华区
<Route author="nczitzk" example="/cool18/bbs4/gold" path="/cool18/bbs4/gold"/>
### 栏目分类
<Route author="nczitzk" example="/cool18/bbs4/type/都市" path="/cool18/bbs4/type/:keyword?" :paramsDesc="['分类,见下表,默认为首页']">
| 都市 | 校园 | 乡野 | 古风 | 异国 | 玄幻 | 红杏 | 伦理 | 浪漫 | 暴虐 | 摄心 | 其他 |
| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- |
</Route>
### 搜索关键字
<Route author="nczitzk" example="/cool18/bbs4/keywords/都市" path="/cool18/bbs4/keywords/:keyword?" :paramsDesc="['关键字']"/>
## 孔夫子旧书网
+3
View File
@@ -3670,6 +3670,9 @@ router.get('/proletar/:type?/:id?', require('./routes/proletar/index'));
// QTTabBar
router.get('/qttabbar/change-log', require('./routes/qttabbar/change-log'));
// 酷18
router.get('/cool18/:id?/:type?/:keyword?', require('./routes/cool18/index'));
// 美国贸易代表办公室
router.get('/ustr/press-releases/:year?/:month?', require('./routes/us/ustr/press-releases'));
+58
View File
@@ -0,0 +1,58 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const id = ctx.params.id || 'bbs4';
const type = ctx.params.type || '';
const keyword = ctx.params.keyword || '';
const rootUrl = 'https://www.cool18.com';
const indexUrl = `${rootUrl}/${id}/index.php`;
const currentUrl = `${indexUrl}${type === '' || keyword === '' ? '' : type === 'gold' ? '?app=forum&act=gold' : `?action=search&act=threadsearch&app=forum&${type}=${keyword}&submit=${type === 'type' ? '查询' : '栏目搜索'}`}`;
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data);
const list = $('#d_list ul li, #thread_list li, .t_l .t_subject')
.slice(0, 10)
.map((_, item) => {
item = $(item);
const a = item.find('a').eq(0);
return {
link: `${rootUrl}/${id}/${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 content = cheerio.load(detailResponse.data);
item.title = content('title').text().replace(' - cool18.com', '');
item.author = detailResponse.data.match(/送交者: .*>(.*)<.*\[/)[1];
item.pubDate = new Date(detailResponse.data.match(/于 (.*) 已读/)[1]).toUTCString();
item.description = content('pre')
.html()
.replace(/<font color="#E6E6DD">cool18.com<\/font>/g, '');
return item;
})
)
);
ctx.state.data = {
title: $('title').text(),
link: currentUrl,
item: items,
};
};