add 安徽建筑大学 通知公告 (#8807)
Co-authored-by: yuk7-0v0 <91721784+yuk7-0v0@users.noreply.github.com>
This commit is contained in:
parent
ce9743012a
commit
805338babd
|
|
@ -52,6 +52,12 @@ pageClass: routes
|
|||
|
||||
<Route author="Diffumist" example="/ahut/cstzgg" path="/ahut/cstzgg" />
|
||||
|
||||
## 安徽建筑大学
|
||||
|
||||
### 通知公告
|
||||
|
||||
<Route author="Yuk-0v0" example="/ahjzu/news" path="/ahjzu/news" />
|
||||
|
||||
## 安徽农业大学
|
||||
|
||||
### 计算机学院
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/news': ['Yuk-0v0'],
|
||||
};
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'https://www.ahjzu.edu.cn';
|
||||
const currentUrl = 'https://www.ahjzu.edu.cn/20/list.htm';
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('#wp_news_w9')
|
||||
.find('li')
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
const date = item.find('.column-news-date').text();
|
||||
|
||||
// 置顶链接自带http前缀,其他不带,需要手动判断
|
||||
const a = item.find('a').attr('href');
|
||||
const link = a.slice(0, 4) !== 'http' ? rootUrl + a : a;
|
||||
return {
|
||||
title: item.find('a').attr('title'),
|
||||
link,
|
||||
pubDate: timezone(parseDate(date), +8),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
const post = content('.wp_articlecontent').html();
|
||||
|
||||
item.description = post;
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '安建大-通知公告',
|
||||
description: '安徽建筑大学-通知公告',
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'ahjzu.edu.cn': {
|
||||
_name: '安徽建筑大学',
|
||||
news: [
|
||||
{
|
||||
title: '通知公告',
|
||||
docs: 'https://docs.rsshub.app/university.html#an-hui-jian-zhu-da-xue',
|
||||
source: '/20/list.htm',
|
||||
target: '/ahjzu/news',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/news', require('./news'));
|
||||
};
|
||||
Loading…
Reference in New Issue