feat: add 中国科学院信息工程研究所 (#5285)

This commit is contained in:
Jiaxi ® 2020-07-29 21:38:20 +08:00 committed by GitHub
parent baec2b6243
commit ee5bee804d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 0 deletions

View File

@ -1785,6 +1785,10 @@ type 列表:
<Route author="HenryQW" example="/cas/sim/academic" path="/cas/sim/academic"/>
### 中国科学院信息工程研究所 第二研究室 处理架构组 知识库
<Route author="renzhexigua" example="/cas/mesalab/kb" path="/cas/mesalab/kb"/>
## 中国农业大学
### 中国农业大学研招网通知公告

View File

@ -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'));

View File

@ -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();
};