From 805338babd925e1f34bd01875da10d7515d35804 Mon Sep 17 00:00:00 2001
From: Yuk <40992553+Yuk-0v0@users.noreply.github.com>
Date: Sun, 23 Jan 2022 03:03:54 +0800
Subject: [PATCH] =?UTF-8?q?add=20=E5=AE=89=E5=BE=BD=E5=BB=BA=E7=AD=91?=
=?UTF-8?q?=E5=A4=A7=E5=AD=A6=20=E9=80=9A=E7=9F=A5=E5=85=AC=E5=91=8A=20(#8?=
=?UTF-8?q?807)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-authored-by: yuk7-0v0 <91721784+yuk7-0v0@users.noreply.github.com>
---
docs/university.md | 6 ++++
lib/v2/ahjzu/maintainer.js | 3 ++
lib/v2/ahjzu/news.js | 57 ++++++++++++++++++++++++++++++++++++++
lib/v2/ahjzu/radar.js | 13 +++++++++
lib/v2/ahjzu/router.js | 3 ++
5 files changed, 82 insertions(+)
create mode 100644 lib/v2/ahjzu/maintainer.js
create mode 100644 lib/v2/ahjzu/news.js
create mode 100644 lib/v2/ahjzu/radar.js
create mode 100644 lib/v2/ahjzu/router.js
diff --git a/docs/university.md b/docs/university.md
index 6e057a726..68b732306 100644
--- a/docs/university.md
+++ b/docs/university.md
@@ -52,6 +52,12 @@ pageClass: routes
+## 安徽建筑大学
+
+### 通知公告
+
+
+
## 安徽农业大学
### 计算机学院
diff --git a/lib/v2/ahjzu/maintainer.js b/lib/v2/ahjzu/maintainer.js
new file mode 100644
index 000000000..236f1cacd
--- /dev/null
+++ b/lib/v2/ahjzu/maintainer.js
@@ -0,0 +1,3 @@
+module.exports = {
+ '/news': ['Yuk-0v0'],
+};
diff --git a/lib/v2/ahjzu/news.js b/lib/v2/ahjzu/news.js
new file mode 100644
index 000000000..832e9c802
--- /dev/null
+++ b/lib/v2/ahjzu/news.js
@@ -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,
+ };
+};
diff --git a/lib/v2/ahjzu/radar.js b/lib/v2/ahjzu/radar.js
new file mode 100644
index 000000000..bafbb9a53
--- /dev/null
+++ b/lib/v2/ahjzu/radar.js
@@ -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',
+ },
+ ],
+ },
+};
diff --git a/lib/v2/ahjzu/router.js b/lib/v2/ahjzu/router.js
new file mode 100644
index 000000000..69a5972f6
--- /dev/null
+++ b/lib/v2/ahjzu/router.js
@@ -0,0 +1,3 @@
+module.exports = function (router) {
+ router.get('/news', require('./news'));
+};