From ee5bee804d30ec5044a30cca6ec93855e4bbdfbf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jiaxi=20=C2=AE?=
<4772169+renzhexigua@users.noreply.github.com>
Date: Wed, 29 Jul 2020 21:38:20 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20add=20=E4=B8=AD=E5=9B=BD=E7=A7=91?=
=?UTF-8?q?=E5=AD=A6=E9=99=A2=E4=BF=A1=E6=81=AF=E5=B7=A5=E7=A8=8B=E7=A0=94?=
=?UTF-8?q?=E7=A9=B6=E6=89=80=20(#5285)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
docs/university.md | 4 ++
lib/router.js | 1 +
lib/routes/universities/cas/mesalab/kb.js | 45 +++++++++++++++++++++++
3 files changed, 50 insertions(+)
create mode 100644 lib/routes/universities/cas/mesalab/kb.js
diff --git a/docs/university.md b/docs/university.md
index 670119ad7..88586ac08 100644
--- a/docs/university.md
+++ b/docs/university.md
@@ -1785,6 +1785,10 @@ type 列表:
+### 中国科学院信息工程研究所 第二研究室 处理架构组 知识库
+
+
+
## 中国农业大学
### 中国农业大学研招网通知公告
diff --git a/lib/router.js b/lib/router.js
index 4d7058436..b3378f269 100644
--- a/lib/router.js
+++ b/lib/router.js
@@ -654,6 +654,7 @@ router.get('/gdut/news', require('./routes/universities/gdut/news'));
// 中国科学院
router.get('/cas/sim/academic', require('./routes/universities/cas/sim/academic'));
+router.get('/cas/mesalab/kb', require('./routes/universities/cas/mesalab/kb'));
// 中国传媒大学
router.get('/cuc/yz', require('./routes/universities/cuc/yz'));
diff --git a/lib/routes/universities/cas/mesalab/kb.js b/lib/routes/universities/cas/mesalab/kb.js
new file mode 100644
index 000000000..7f8f2934a
--- /dev/null
+++ b/lib/routes/universities/cas/mesalab/kb.js
@@ -0,0 +1,45 @@
+const cherrio = require('cheerio');
+const got = require('@/utils/got');
+
+module.exports = async (ctx, next) => {
+ const homepage = 'https://www.mesalab.cn';
+ const response = await got({
+ method: 'get',
+ url: `${homepage}/f/article/articleList?pageNo=1&pageSize=15&createTimeSort=DESC`,
+ });
+
+ const $ = cherrio.load(response.data);
+ const articles = $('.aw-item').get();
+
+ const items = await Promise.all(
+ articles.map(async (item) => {
+ const article = $(item).find('.aw-item-content > p').first();
+ const title = article
+ .text()
+ .replace(/(\r\n|\n|\r)/gm, ' ')
+ .trim();
+ const link = `${homepage}/${article.find('a').attr('href')}`;
+
+ return await ctx.cache.tryGet(link, async () => {
+ const result = await got.get(link);
+ const $ = cherrio.load(result.body);
+ return {
+ title,
+ author: $('.user_name').text(),
+ pubDate: new Date($('.link_postdate').text().replace(/\s+/g, ' ')).toUTCString(),
+ description: $('#article_details').html(),
+ link,
+ };
+ });
+ })
+ );
+
+ ctx.state.data = {
+ title: 'MESA 知识库',
+ description: '中国科学院信息工程研究所 第二研究室 处理架构组',
+ link: homepage,
+ item: items,
+ };
+
+ await next();
+};