From c60eb7e052cfe5e12936eb709f03234b70252d8b Mon Sep 17 00:00:00 2001 From: Ethan Shen Date: Mon, 5 Oct 2020 21:56:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20add=20=E4=B8=AD=E5=9B=BD=E5=B7=A5?= =?UTF-8?q?=E7=A8=8B=E7=A7=91=E6=8A=80=E7=9F=A5=E8=AF=86=E4=B8=AD=E5=BF=83?= =?UTF-8?q?=E7=9F=A5=E8=AF=86=E5=BA=94=E7=94=A8=20(#5802)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Henry Wang --- docs/other.md | 19 +++++++++++++++++++ lib/router.js | 2 ++ lib/routes/cktest/app.js | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 lib/routes/cktest/app.js diff --git a/docs/other.md b/docs/other.md index 3f8422757..4ddae78c4 100644 --- a/docs/other.md +++ b/docs/other.md @@ -829,3 +829,22 @@ type 为 all 时,category 参数不支持 cost 和 free ### はてな匿名ダイアリー - 人気記事アーカイブ + +## 中国工程科技知识中心 + +### 知识应用 + + + +所属类别 + +| 专题知识服务 | 知识分析 | 知识工具 | 综合性知识服务 | 全部类别 | +| ------------ | -------- | -------- | -------------- | -------- | +| 2 | 3 | 4 | 1 | 0 | + +领域 + +| 综合 | 农业 | 航天 | 地质 | 信息技术 | 林业 | 医药卫生 | 战略性新兴产业 | 能源 | 冶金 | 化工 | 地理信息 | 营养健康 | 工程科教图书 | 交通 | 创新设计 | 地理资源与生态 | 材料 | 气象 | 渔业 | 环境工程 | 试验技术 | 中草药 | 水利 | 海洋工程 | +| ---- | ---- | ---- | ---- | -------- | ---- | -------- | -------------- | ---- | ---- | ---- | -------- | -------- | ------------ | ---- | -------- | -------------- | ---- | ---- | ---- | -------- | -------- | ------ | ---- | -------- | + + diff --git a/lib/router.js b/lib/router.js index af708052a..74b3fc3f5 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3257,6 +3257,8 @@ router.get('/appsales/:caty?/:time?', require('./routes/appsales/index')); // CGTN router.get('/cgtn/top', require('./routes/cgtn/top')); +// 中国工程科技知识中心 +router.get('/cktest/app/:ctgroup?/:domain?', require('./routes/cktest/app')); // 妈咪帮 router.get('/mamibuy/:caty?/:age?/:sort?', require('./routes/mamibuy/index')); diff --git a/lib/routes/cktest/app.js b/lib/routes/cktest/app.js new file mode 100644 index 000000000..426763259 --- /dev/null +++ b/lib/routes/cktest/app.js @@ -0,0 +1,34 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const ctgroup = ctx.params.ctgroup ? (ctx.params.ctgroup === '0' ? '' : 'CTGRGUP==' + ctx.params.ctgroup) : ''; + const domain = ctx.params.domain ? 'DOMAIN==' + ctx.params.domain : ''; + + const rootUrl = `http://www.ckcest.cn/home/app/list?category=${ctgroup}${ctgroup && domain ? ' AND ' : ''}${domain}`; + const response = await got({ + method: 'get', + url: rootUrl, + }); + + const $ = cheerio.load(response.data); + const items = $('.search-result-list') + .map((_, item) => { + item = $(item); + const a = item.find('h4.sc-title a'); + return { + title: a.text(), + link: a.attr('href'), + description: item.find('.applySummary-new').text(), + author: item.find('.applyInfor-new span').eq(1).text(), + pubDate: new Date(item.find('.applyInfor-new span').eq(0).text() + ' GMT+8').toUTCString(), + }; + }) + .get(); + + ctx.state.data = { + title: '知识应用 - 中国工程科技知识中心', + link: rootUrl, + item: items, + }; +};