From 21cd347aa41c1af29ee41b94930ee41058860886 Mon Sep 17 00:00:00 2001 From: junfengP <840282629@qq.com> Date: Tue, 4 Jun 2019 10:55:55 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20=E8=89=B2=E5=8D=8E?= =?UTF-8?q?=E5=A0=82=20-=20=E8=89=B2=E8=8A=B1=E5=9B=BE=E7=89=87=20?= =?UTF-8?q?=E7=89=88=E5=9D=97=20(#2293)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/multimedia.md | 10 ++++ lib/router.js | 6 ++- lib/routes/dsndsht23/pictures.js | 87 ++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 lib/routes/dsndsht23/pictures.js diff --git a/docs/multimedia.md b/docs/multimedia.md index 9d6c3271f..2f96f2283 100644 --- a/docs/multimedia.md +++ b/docs/multimedia.md @@ -230,6 +230,16 @@ pageClass: routes +### 色花图片 + + + +| 华人性爱自拍 | 华人街拍区 | 亚洲性爱 | 欧美性爱 | 卡通动漫 | +| ------------ | ---------- | -------- | -------- | -------- | +| hrxazp | hrjpq | yzxa | omxa | ktdm | + + + ## 腾讯视频 ### 播放列表 diff --git a/lib/router.js b/lib/router.js index a3b008d27..dde8c9788 100644 --- a/lib/router.js +++ b/lib/router.js @@ -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')); diff --git a/lib/routes/dsndsht23/pictures.js b/lib/routes/dsndsht23/pictures.js new file mode 100644 index 000000000..be0f99040 --- /dev/null +++ b/lib/routes/dsndsht23/pictures.js @@ -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(``); + description += ``; + } + } + // 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, + }; +};