feat: 增加 色华堂 - 色花图片 版块 (#2293)

This commit is contained in:
junfengP
2019-06-04 10:55:55 +08:00
committed by DIYgod
parent b7c917c624
commit 21cd347aa4
3 changed files with 102 additions and 1 deletions
+10
View File
@@ -230,6 +230,16 @@ pageClass: routes
</Route>
### 色花图片
<Route author="junfengP" example="/dsndsht23/picture/hrxazp" path="/dsndsht23/picture/:subforumid" :paramsDesc="['子版块 id']">
| 华人性爱自拍 | 华人街拍区 | 亚洲性爱 | 欧美性爱 | 卡通动漫 |
| ------------ | ---------- | -------- | -------- | -------- |
| hrxazp | hrjpq | yzxa | omxa | ktdm |
</Route>
## 腾讯视频
### 播放列表
+5 -1
View File
@@ -1330,7 +1330,11 @@ router.get('/yuque/doc/:repo_id', require('./routes/yuque/doc'));
// 飞地
router.get('/enclavebooks/category/:id?', require('./routes/enclavebooks/category'));
// 色花堂
// 色花堂 - 色花图片版块
router.get('/dsndsht23/picture/:subforumid', require('./routes/dsndsht23/pictures'));
// 色花堂 - 原创bt电影
router.get('/dsndsht23/bt/:subforumid', require('./routes/dsndsht23/index'));
router.get('/dsndsht23/:subforumid', require('./routes/dsndsht23/index'));
router.get('/dsndsht23', require('./routes/dsndsht23/index'));
+87
View File
@@ -0,0 +1,87 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const host = 'https://www.dsndsht23.com/';
const map = {
hrxazp: 'forum-98-1.html',
hrjpq: 'forum-50-1.html',
yzxa: 'forum-48-1.html',
omxa: 'forum-49-1.html',
ktdm: 'forum-117-1.html',
};
module.exports = async (ctx) => {
const subforumid = ctx.params.subforumid || 'hrxazp';
const link = `https://www.dsndsht23.com/${map[subforumid]}`;
const response = await got.get(link);
const $ = cheerio.load(response.body);
const list = $('#threadlisttableid tbody')
.slice(1, 21)
.filter(function() {
// 去除置顶帖子和分割线
const threadID = $(this).attr('id');
return threadID !== 'separatorline' && !threadID.startsWith('stickthread');
})
.map(function() {
const info = {
title: $(this)
.find('a.xst')
.text(),
link: $(this)
.find('a.xst')
.attr('href'),
date: $(this)
.find('td.by')
.find('em span span')
.attr('title'),
};
return info;
})
.get();
const out = await Promise.all(
list.map(async (info) => {
const title = info.title;
const date = info.date;
const itemUrl = host + info.link;
const cache = await ctx.cache.get(itemUrl);
if (cache) {
return Promise.resolve(JSON.parse(cache));
}
const response = await got.get(itemUrl);
const $ = cheerio.load(response.data);
const postMessage = $("td[id^='postmessage']").slice(0, 1);
const images = $(postMessage).find('img');
let description = '';
for (let k = 0; k < images.length; k++) {
if (!$(images[k]).attr('file') || $(images[k]).attr('file') === 'undefined') {
$(images[k]).replaceWith('');
} else {
// $(images[k]).replaceWith(`<img src="${$(images[k]).attr('file')}" referrerpolicy="no-referrer" />`);
description += `<img src="${$(images[k]).attr('file')}" referrerpolicy="no-referrer" />`;
}
}
// const description = postMessage.html();
const single = {
title: title,
link: itemUrl,
description: description,
pubDate: new Date(date).toUTCString(),
};
ctx.cache.set(itemUrl, JSON.stringify(single));
return Promise.resolve(single);
})
);
ctx.state.data = {
title: `色花堂 - ${$('#pt > div:nth-child(1) > a:last-child').text()}`,
link: link,
item: out,
};
};