feat: 新增复旦大学继续教育学院校园通知 (#6274)
This commit is contained in:
parent
6ce6d0c7c5
commit
6c5198f728
|
|
@ -440,6 +440,12 @@ xskb1 对应 <http://www.auto.uestc.edu.cn/index/xskb1.htm>
|
|||
|
||||
</Route>
|
||||
|
||||
## 复旦大学继续教育学院
|
||||
|
||||
### 成人夜大通知公告
|
||||
|
||||
<Route author="mrbruce516" example="/fudan/cce" path="/fudan/cce" />
|
||||
|
||||
## 福州大学
|
||||
|
||||
### 教务处教学通知
|
||||
|
|
|
|||
|
|
@ -3604,4 +3604,7 @@ router.get('/deloitte/industries/:category?', require('./routes/deloitte/industr
|
|||
// 特斯拉系统更新
|
||||
router.get('/tesla', require('./routes/tesla/update'));
|
||||
|
||||
// 复旦大学继续教育学院
|
||||
router.get('/fudan/cce', require('./routes/universities/fudan/cce'));
|
||||
|
||||
module.exports = router;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,52 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
const host = 'http://www.cce.fudan.edu.cn';
|
||||
const link = 'http://www.cce.fudan.edu.cn/14096/list.htm';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: link,
|
||||
headers: {
|
||||
Referer: host,
|
||||
},
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const urlList = $('.Article_Title a')
|
||||
.get()
|
||||
.map((i) => host + $(i).attr('href'));
|
||||
|
||||
const out = await Promise.all(
|
||||
urlList.map(async (itemUrl) => {
|
||||
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 targetDate = $('.arti_update')
|
||||
.text()
|
||||
.match(/(\d{4}-\d{2})-\d{2}/);
|
||||
|
||||
if (targetDate) {
|
||||
const single = {
|
||||
title: $('.arti_title').text(),
|
||||
link: itemUrl,
|
||||
description: $('.wp_articlecontent').html(),
|
||||
pubDate: targetDate[0],
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '复旦大学继续教育学院 - 通知公告',
|
||||
link,
|
||||
item: out.filter((i) => i),
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue