From 22b9c87565d5a67b0b9f9be606df40a6be3f3138 Mon Sep 17 00:00:00 2001 From: Ethan Shen Date: Sun, 28 Jun 2020 11:38:42 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20add=20=E6=89=8D=E5=BA=9C=E7=A4=BE?= =?UTF-8?q?=E5=8C=BA=E7=94=A8=E6=88=B7=E5=8A=A8=E6=80=81=20(#5074)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/bbs.md | 6 ++++++ lib/router.js | 3 +++ lib/routes/91ddcc/user.js | 30 ++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 lib/routes/91ddcc/user.js diff --git a/docs/bbs.md b/docs/bbs.md index cf49eb0e6..7bec6e41d 100644 --- a/docs/bbs.md +++ b/docs/bbs.md @@ -168,6 +168,12 @@ pageClass: routes +## 才符 + +### 用户动态 + + + ## 电鸭社区 ### 工作机会 diff --git a/lib/router.js b/lib/router.js index fb2541e9f..c8840bec3 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2874,6 +2874,9 @@ router.get('/changku', require('./routes/changku/index')); // 上海市生态环境局 router.get('/gov/shanghai/sthj', require('./routes/gov/shanghai/sthj')); +// 才符 +router.get('/91ddcc/user/:user', require('./routes/91ddcc/user')); + // BookwalkerTW热门新书 router.get('/bookwalkertw/news', require('./routes/bookwalkertw/news')); diff --git a/lib/routes/91ddcc/user.js b/lib/routes/91ddcc/user.js new file mode 100644 index 000000000..097b85cda --- /dev/null +++ b/lib/routes/91ddcc/user.js @@ -0,0 +1,30 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const currentUrl = `https://sns.91ddcc.com/${ctx.params.user}`; + const response = await got({ + method: 'get', + url: currentUrl, + }); + const $ = cheerio.load(response.data); + const list = $('div.dynamic-single') + .slice(0, 10) + .map((_, item) => { + item = $(item); + const word = item.find('div.word'); + return { + title: item.find('div.detail-time').text(), + link: `https://sns.91ddcc.com/${item.attr('id').split('-')[1]}`, + description: word.html(), + pubDate: new Date(item.find('div.detail-time').text() + ' GMT+8').toUTCString(), + }; + }) + .get(); + + ctx.state.data = { + title: `${$('span.user-name').text()} - 才符`, + link: currentUrl, + item: list, + }; +};