mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-10 15:21:59 +08:00
@@ -24,6 +24,12 @@ pageClass: routes
|
||||
|
||||
<Route author="exuanbo" example="/polimi/news" path="/polimi/news/:language?" :paramsDesc="['English language code en']" />
|
||||
|
||||
## 安徽医科大学
|
||||
|
||||
### 研究生学院通知公告
|
||||
|
||||
<Route author="Origami404" example="/ahmu/news" path="/ahmu/news" />
|
||||
|
||||
## 北华航天工业学院
|
||||
|
||||
### 新闻
|
||||
|
||||
@@ -765,6 +765,9 @@ router.get('/ncwu/notice', require('./routes/universities/ncwu/notice'));
|
||||
// 中北大学
|
||||
router.get('/nuc/:type', require('./routes/universities/nuc/index'));
|
||||
|
||||
// 安徽医科大学研究生学院
|
||||
router.get('/ahmu/news', require('./routes/universities/ahmu/news'));
|
||||
|
||||
// ifanr
|
||||
router.get('/ifanr/:channel?', require('./routes/ifanr/index'));
|
||||
|
||||
|
||||
51
lib/routes/universities/ahmu/news.js
Normal file
51
lib/routes/universities/ahmu/news.js
Normal file
@@ -0,0 +1,51 @@
|
||||
const got = require('@/utils/got');
|
||||
const date = require('@/utils/date');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const url = 'http://yjsxy.ahmu.edu.cn/_s62/1840/list.psp';
|
||||
const response = await got({ method: 'get', url });
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('#wp_news_w3 table tbody')
|
||||
.map((i, e) => {
|
||||
const element = $(e);
|
||||
const title = element.find('a').text();
|
||||
const link = element.find('a').attr('href');
|
||||
const dateraw = /(\d{4})\/(\d{2})(\d{2})/.exec(link);
|
||||
|
||||
return {
|
||||
title: title,
|
||||
description: '',
|
||||
link: url + link,
|
||||
author: '安徽医科大学研究生学院',
|
||||
pubDate: date(`${dateraw[1]}-${dateraw[2]}-${dateraw[3]}`),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const result = await Promise.all(
|
||||
list.map(async (item) => {
|
||||
const link = item.link;
|
||||
|
||||
const cache = await ctx.cache.get(link);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
|
||||
const itemReponse = await got.get(link);
|
||||
const itemElement = cheerio.load(itemReponse.data);
|
||||
|
||||
item.description = itemElement('.content').html();
|
||||
|
||||
ctx.cache.set(link, JSON.stringify(item));
|
||||
return Promise.resolve(item);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '安徽医科大学研究生学院',
|
||||
link: url,
|
||||
item: result,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user