add 安徽建筑大学 通知公告 (#8807)

Co-authored-by: yuk7-0v0 <91721784+yuk7-0v0@users.noreply.github.com>
This commit is contained in:
Yuk 2022-01-23 03:03:54 +08:00 committed by GitHub
parent ce9743012a
commit 805338babd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 82 additions and 0 deletions

View File

@ -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" />
## 安徽农业大学
### 计算机学院

View File

@ -0,0 +1,3 @@
module.exports = {
'/news': ['Yuk-0v0'],
};

57
lib/v2/ahjzu/news.js Normal file
View File

@ -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,
};
};

13
lib/v2/ahjzu/radar.js Normal file
View File

@ -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',
},
],
},
};

3
lib/v2/ahjzu/router.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/news', require('./news'));
};