mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-19 06:38:55 +08:00
fix(route): remove next() from mesalab route (#11835)
* fix(route): remove next() from mesalab route * refactor: migrate to v2 http://www.sim.cas.cn/xwzx2016/xshd2016/ is dead ---------
This commit is contained in:
@@ -3477,7 +3477,7 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
|
||||
|
||||
### 成果转化
|
||||
|
||||
<Route author="nczitzk" example="/cas/cg/cgzhld" path="/cas/cg/:caty?" :paramsDesc="['分类,见下表,默认为工作动态']">
|
||||
<Route author="nczitzk" example="/cas/cg/cgzhld" path="/cas/cg/:caty?" :paramsDesc="['分类,见下表,默认为工作动态']" radar="1">
|
||||
|
||||
| 工作动态 | 科技成果转移转化亮点工作 |
|
||||
| ---- | ------------ |
|
||||
@@ -3485,17 +3485,17 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
|
||||
|
||||
</Route>
|
||||
|
||||
### 上海微系统与信息技术研究所学术活动
|
||||
### 上海微系统与信息技术研究所 科技进展
|
||||
|
||||
<Route author="HenryQW" example="/cas/sim/academic" path="/cas/sim/academic"/>
|
||||
<Route author="HenryQW" example="/cas/sim/kyjz" path="/cas/sim/kyjz" radar="1"/>
|
||||
|
||||
### 中国科学院信息工程研究所 第二研究室 处理架构组 知识库
|
||||
### 信息工程研究所 第二研究室 处理架构组 知识库
|
||||
|
||||
<Route author="renzhexigua" example="/cas/mesalab/kb" path="/cas/mesalab/kb"/>
|
||||
<Route author="renzhexigua" example="/cas/mesalab/kb" path="/cas/mesalab/kb" radar="1"/>
|
||||
|
||||
### 中国科学院电工研究所 科研动态
|
||||
### 电工研究所 科研动态
|
||||
|
||||
<Route author="nczitzk" example="/cas/iee/kydt" path="/cas/iee/kydt"/>
|
||||
<Route author="nczitzk" example="/cas/iee/kydt" path="/cas/iee/kydt" radar="1"/>
|
||||
|
||||
## 中国科学院大学
|
||||
|
||||
|
||||
@@ -590,10 +590,10 @@ router.get('/scnu/cs/match', lazyloadRouteHandler('./routes/universities/scnu/cs
|
||||
// router.get('/gdut/news', lazyloadRouteHandler('./routes/universities/gdut/news'));
|
||||
|
||||
// 中国科学院
|
||||
router.get('/cas/sim/academic', lazyloadRouteHandler('./routes/universities/cas/sim/academic'));
|
||||
router.get('/cas/mesalab/kb', lazyloadRouteHandler('./routes/universities/cas/mesalab/kb'));
|
||||
router.get('/cas/iee/kydt', lazyloadRouteHandler('./routes/universities/cas/iee/kydt'));
|
||||
router.get('/cas/cg/:caty?', lazyloadRouteHandler('./routes/universities/cas/cg/index'));
|
||||
// router.get('/cas/sim/academic', lazyloadRouteHandler('./routes/universities/cas/sim/academic'));
|
||||
// router.get('/cas/mesalab/kb', lazyloadRouteHandler('./routes/universities/cas/mesalab/kb'));
|
||||
// router.get('/cas/iee/kydt', lazyloadRouteHandler('./routes/universities/cas/iee/kydt'));
|
||||
// router.get('/cas/cg/:caty?', lazyloadRouteHandler('./routes/universities/cas/cg/index'));
|
||||
|
||||
// 中国传媒大学
|
||||
// router.get('/cuc/yz', lazyloadRouteHandler('./v2/cuc/yz'));
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
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((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 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();
|
||||
};
|
||||
@@ -1,59 +0,0 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const url = require('url');
|
||||
|
||||
const host = 'http://www.sim.cas.cn/';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const link = url.resolve(host, 'xwzx2016/xshd2016/');
|
||||
const response = await got.get(link);
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('.list-news li')
|
||||
.slice(0, 10)
|
||||
.map((i, e) =>
|
||||
$(e).children().length > 0
|
||||
? {
|
||||
link: $(e).find('a').attr('href'),
|
||||
date: $(e).find('span').text().replace('[', '').replace(']', ''),
|
||||
}
|
||||
: null
|
||||
)
|
||||
.get();
|
||||
|
||||
const out = await Promise.all(
|
||||
list.map(async (item) => {
|
||||
const itemUrl = url.resolve(link, item.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 author = $('.qtinfo.hidden-lg.hidden-md.hidden-sm').text();
|
||||
const reg = new RegExp('文章来源:(.*?)\\|', 'g');
|
||||
|
||||
const single = {
|
||||
title: $('p.wztitle').text().trim(),
|
||||
link: itemUrl,
|
||||
author: reg.exec(author)[1].toString().trim(),
|
||||
description: $('.TRS_Editor')
|
||||
.html()
|
||||
.replace(/src=".\//g, `src="${url.resolve(itemUrl, '.')}`)
|
||||
.trim(),
|
||||
pubDate: new Date(item.date).toUTCString(),
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '中国科学院上海微系统与信息技术研究所 -- 学术活动',
|
||||
link,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
@@ -1,11 +1,13 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
ctx.params.caty = ctx.params.caty || 'zh';
|
||||
|
||||
const rootUrl = 'https://www.cas.cn';
|
||||
const currentUrl = `${rootUrl}/cg/${ctx.params.caty}`;
|
||||
const currentUrl = `${rootUrl}/cg/${ctx.params.caty}/`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
@@ -35,7 +37,7 @@ module.exports = async (ctx) => {
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.description = content('.TRS_Editor').html();
|
||||
item.pubDate = new Date(content('meta[name="PubDate"]').attr('content') + ' GMT+8').toUTCString();
|
||||
item.pubDate = timezone(parseDate(content('meta[name="PubDate"]').attr('content')), 8);
|
||||
|
||||
return item;
|
||||
})
|
||||
@@ -1,8 +1,10 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'http://www.iee.cas.cn/xwzx/kydt';
|
||||
const rootUrl = 'http://www.iee.cas.cn/xwzx/kydt/';
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: rootUrl,
|
||||
@@ -11,15 +13,15 @@ module.exports = async (ctx) => {
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('li.entry .entry-content-title')
|
||||
.slice(0, 15)
|
||||
.map((_, item) => {
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
const a = item.find('a');
|
||||
return {
|
||||
title: a.text(),
|
||||
link: a.attr('href'),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
});
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
@@ -31,7 +33,7 @@ module.exports = async (ctx) => {
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.description = content('.article-content').html();
|
||||
item.pubDate = new Date(content('time').text().split(':')[1] + ' GMT+8').toUTCString();
|
||||
item.pubDate = timezone(parseDate(content('time').text().split(':')[1]), 8);
|
||||
|
||||
return item;
|
||||
})
|
||||
6
lib/v2/cas/maintainer.js
Normal file
6
lib/v2/cas/maintainer.js
Normal file
@@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
'/cg/:caty?': ['nczitzk'],
|
||||
'/iee/kydt': ['nczitzk'],
|
||||
'/mesalab/kb': ['renzhexigua'],
|
||||
'/sim/kyjz': ['HenryQW'],
|
||||
};
|
||||
41
lib/v2/cas/mesalab/kb.js
Normal file
41
lib/v2/cas/mesalab/kb.js
Normal file
@@ -0,0 +1,41 @@
|
||||
const cherrio = require('cheerio');
|
||||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const homepage = 'https://www.mesalab.cn';
|
||||
const url = `${homepage}/f/article/articleList?pageNo=1&pageSize=15&createTimeSort=DESC`;
|
||||
const response = await got(url);
|
||||
|
||||
const $ = cherrio.load(response.data);
|
||||
const articles = $('.aw-item').toArray();
|
||||
|
||||
const items = await Promise.all(
|
||||
articles.map((item) => {
|
||||
const a = $(item).find('a').first();
|
||||
const title = a.text().trim();
|
||||
const link = `${homepage}${a.attr('href')}`;
|
||||
|
||||
return ctx.cache.tryGet(link, async () => {
|
||||
const result = await got(link);
|
||||
const $ = cherrio.load(result.data);
|
||||
return {
|
||||
title,
|
||||
author: $('.user_name').text(),
|
||||
pubDate: timezone(parseDate($('.link_postdate').text().replace(/\s+/g, ' ')), 8),
|
||||
description: $('#article_content').html() + ($('.attachment').length ? $('.attachment').html() : ''),
|
||||
link,
|
||||
category: $('.category .category_r span').first().text(),
|
||||
};
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'MESA 知识库',
|
||||
description: '中国科学院信息工程研究所 第二研究室 处理架构组',
|
||||
link: url,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
40
lib/v2/cas/radar.js
Normal file
40
lib/v2/cas/radar.js
Normal file
@@ -0,0 +1,40 @@
|
||||
module.exports = {
|
||||
'cas.cn': {
|
||||
_name: '中国科学院',
|
||||
www: [
|
||||
{
|
||||
title: '成果转化',
|
||||
docs: 'https://docs.rsshub.app/university.html#zhong-guo-ke-xue-yuan',
|
||||
source: ['/cg/:caty?'],
|
||||
target: '/cas/cg/:caty?',
|
||||
},
|
||||
],
|
||||
'www.sim': [
|
||||
{
|
||||
title: '上海微系统与信息技术研究所 - 科技进展',
|
||||
docs: 'https://docs.rsshub.app/university.html#zhong-guo-ke-xue-yuan',
|
||||
source: ['/xwzx2016/kyjz/', '/'],
|
||||
target: '/cas/sim/kyjz',
|
||||
},
|
||||
],
|
||||
'www.iee': [
|
||||
{
|
||||
title: '电工研究所 科研动态',
|
||||
docs: 'https://docs.rsshub.app/university.html#zhong-guo-ke-xue-yuan',
|
||||
source: ['/xwzx/kydt', '/'],
|
||||
target: '/cas/iee/kydt',
|
||||
},
|
||||
],
|
||||
},
|
||||
'mesalab.cn': {
|
||||
_name: '中国科学院',
|
||||
www: [
|
||||
{
|
||||
title: '信息工程研究所 第二研究室 处理架构组 知识库',
|
||||
docs: 'https://docs.rsshub.app/university.html#zhong-guo-ke-xue-yuan',
|
||||
source: ['/f/article/articleList', '/'],
|
||||
target: '/cas/mesalab/kb',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
6
lib/v2/cas/router.js
Normal file
6
lib/v2/cas/router.js
Normal file
@@ -0,0 +1,6 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/cg/:caty?', require('./cg/index'));
|
||||
router.get('/iee/kydt', require('./iee/kydt'));
|
||||
router.get('/mesalab/kb', require('./mesalab/kb'));
|
||||
router.get('/sim/kyjz', require('./sim/kyjz'));
|
||||
};
|
||||
47
lib/v2/cas/sim/kyjz.js
Normal file
47
lib/v2/cas/sim/kyjz.js
Normal file
@@ -0,0 +1,47 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const host = 'http://www.sim.cas.cn/';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const link = new URL('xwzx2016/kyjz/', host).href;
|
||||
const response = await got(link);
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('.list-news li')
|
||||
.toArray()
|
||||
.filter((e) => !$(e).attr('style'))
|
||||
.map((e) => {
|
||||
e = $(e);
|
||||
return {
|
||||
link: new URL(e.find('a').attr('href'), link).href,
|
||||
pubDate: e.find('span').text().replace('[', '').replace(']', ''),
|
||||
};
|
||||
});
|
||||
|
||||
const out = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const response = await got(item.link);
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const author = $('.qtinfo.hidden-lg.hidden-md.hidden-sm').text();
|
||||
const reg = /文章来源:(.*?)\|/g;
|
||||
|
||||
item.title = $('p.wztitle').text().trim();
|
||||
item.author = reg.exec(author)[1].toString().trim();
|
||||
item.description = $('.TRS_Editor').html();
|
||||
item.pubDate = parseDate(item.pubDate);
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '中国科学院上海微系统与信息技术研究所 -- 科技进展',
|
||||
link,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user