parent
41f5f0a414
commit
87b8eba2ed
|
|
@ -268,6 +268,9 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
|
|||
- 文章
|
||||
- 大连工业大学
|
||||
- 教务处新闻
|
||||
- 中国科学院
|
||||
- 上海微系统与信息技术研究所
|
||||
- 学术活动
|
||||
- ifanr
|
||||
- AppSolution
|
||||
|
||||
|
|
|
|||
|
|
@ -2223,6 +2223,14 @@ type,分类
|
|||
|
||||
参数: 无
|
||||
|
||||
## 中国科学院
|
||||
|
||||
### 上海微系统与信息技术研究所 -- 学术活动 <Author uid="HenryQW"/>
|
||||
|
||||
举例: [https://rsshub.app/cas/sim/academic](https://rsshub.app/cas/sim/academic)
|
||||
|
||||
路由: `/cas/sim/academic`
|
||||
|
||||
## 爱范儿 ifanr <Author uid="HenryQW"/>
|
||||
|
||||
### AppSolution
|
||||
|
|
|
|||
|
|
@ -473,6 +473,9 @@ router.get('/mygalgame', require('./routes/galgame/mygalgame'));
|
|||
// DPU
|
||||
router.get('/dpu/jiaowu/:type?', require('./routes/dpu/jiaowu'));
|
||||
|
||||
// 中国科学院
|
||||
router.get('/cas/sim/academic', require('./routes/cas/sim/academic'));
|
||||
|
||||
// ifanr
|
||||
router.get('/ifanr/appso', require('./routes/ifanr/appso'));
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,70 @@
|
|||
const axios = require('../../../utils/axios');
|
||||
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 axios.get(link);
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('.list-news li')
|
||||
.slice(0, 10)
|
||||
.map((i, e) => {
|
||||
if ($(e).children().length > 0) {
|
||||
return {
|
||||
link: $(e)
|
||||
.find('a')
|
||||
.attr('href'),
|
||||
date: $(e)
|
||||
.find('span')
|
||||
.text()
|
||||
.replace('[', '')
|
||||
.replace(']', ''),
|
||||
};
|
||||
}
|
||||
})
|
||||
.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 axios.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),
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '中国科学院上海微系统与信息技术研究所 -- 学术活动',
|
||||
link,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue