Add 西安理工大学 官网主页 教务处 人事处 (#8799)

Co-authored-by: Tony <TonyRL@users.noreply.github.com>
Co-authored-by: chen <2782772457@qq.com>
This commit is contained in:
mocusez 2022-01-23 03:04:33 +08:00 committed by GitHub
parent 81e1230783
commit 5e18cadf66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 279 additions and 0 deletions

View File

@ -2159,6 +2159,48 @@ type 列表:
<Route author="DylanXie123" example="/xjtu/ee/1114" path="/xjtu/job/:id?" :paramsDesc="['栏目id默认请求`1114`,可在 URL 中找到']" />
## 西安理工大学
### 学校主页
<Route author="mocusez" example="/xaut/index/tzgg" path="/xaut/index/:category?" :paramsDesc="['通知类别,默认为通知公告']" radar="1" rssbud="1" >
| 通知公告 | 校园要闻 | 媒体播报 | 学术活动 |
| :------: | :------: | :------: | :------: |
| tzgg | xyyw | mtbd | xshd |
</Route>
### 教务处
<Route author="mocusez" example="/xaut/jwc/tzgg" path="/xaut/jwc/:category?" :paramsDesc="['通知类别,默认为通知公告']" radar="1" rssbud="1">
::: warning 注意
有些内容需使用校园网或 VPN 访问知行网获取
:::
| 通知公告 | 新闻动态 | 规章制度 | 竞赛结果公示 | 竞赛获奖通知 | 竞赛信息 | 公开公示 |
| :------: | :------: | :------: | :----------: | :----------: | :------: | :------: |
| tzgg | xwdt | gzzd | jggs | jsjg | jsxx | gkgs |
</Route>
### 人事处
<Route author="light0926 mocusez" example="/xaut/rsc/tzgg" path="/xaut/rsc/:category?" :paramsDesc="['通知类别,默认为通知公告']" radar="1" rssbud="1">
::: warning 注意
有些内容指向外部链接目前只提供这些链接不提供具体内容去除jwc和index的修改
:::
| 通知公告 | 工作动态 |
| :------: | :------: |
| tzgg | gzdt |
</Route>
## 西北工业大学
### 翱翔门户

72
lib/v2/xaut/index.js Normal file
View File

@ -0,0 +1,72 @@
const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
let category = ctx.params.category;
const dic_html = { tzgg: 'tzgg.htm', xyyw: 'xyyw.htm', mtbd: 'mtbd1.htm', xshd: 'xshd.htm' };
const dic_title = { tzgg: '通知公告', xyyw: '校园要闻', mtbd: '媒体播报', xshd: '学术活动' };
// 设置默认值
if (dic_title[category] === undefined) {
category = 'tzgg';
}
const response = await got({
method: 'get',
url: 'http://www.xaut.edu.cn/index/' + dic_html[category],
});
const data = response.body;
const $ = cheerio.load(data);
// 这个列表指通知公告详情列表
const list = $('.newslist_block ul a')
.map((_, item) => {
item = $(item);
const temp = item.find('span').text();
// link原来长这样'../info/1196/13990.htm'
const link = item.attr('href').replace(/^\.\./, 'http://www.xaut.edu.cn');
let date = parseDate(temp.slice(-10, -1), 'YYYY-MM-DD');
let title = temp.slice(0, -10);
if (category === 'xshd') {
date = parseDate(temp.slice(-11, -1).replace('年', '-').replace('月', '-').replace('日', ''), 'YYYY-MM-DD');
title = temp.slice(0, -11);
}
return {
title,
link,
pubDate: date,
};
})
.get();
ctx.state.data = {
// 源标题
title: '西安理工大学官网-' + dic_title[category],
// 源链接
link: 'http://www.xaut.edu.cn',
// 源说明
description: `西安理工大学官网-` + dic_title[category],
// 遍历此前获取的数据
item: await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
if (!item.link.match('zhixing.xaut.edu.cn') && !item.link.match('xinwen.xaut.edu.cn')) {
const res = await got({
method: 'get',
url: item.link,
});
const content = cheerio.load(res.body);
item.description = content('#vsb_content').html();
} else {
item.description = '请在校内或校园VPN内查看内容';
}
return item;
})
)
),
};
};

65
lib/v2/xaut/jwc.js Normal file
View File

@ -0,0 +1,65 @@
const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
let category = ctx.params.category;
const rootUrl = 'http://jwc.xaut.edu.cn/';
const dic_html = { tzgg: 'tzgg.htm', xwdt: 'xwdt.htm', gzzd: 'gzzd.htm', jggs: 'xkjs/jggs.htm', jsjg: 'xkjs/jsjg.htm', jsxx: 'xkjs/jsxx.htm', gkgs: 'gkgs.htm' };
const dic_title = { tzgg: '通知公告', xwdt: '新闻动态', gzzd: '规章制度', jggs: '竞赛结果公示', jsjg: '竞赛获奖通知', jsxx: '竞赛信息', gkgs: '公开公示' };
// 设置默认值
if (dic_title[category] === undefined) {
category = 'tzgg';
}
const response = await got({
method: 'get',
url: rootUrl + dic_html[category],
});
const data = response.body;
const $ = cheerio.load(data);
const list = $('.main_conRCb a')
.slice(0, 20)
.map((_, item) => {
item = $(item);
const link = item
.attr('href')
.replace(/^\.\./, rootUrl)
.replace(/^(info)/, rootUrl + 'info');
return {
title: item.find('em').text(),
link,
pubDate: parseDate(item.find('span').text()),
};
})
.get();
ctx.state.data = {
// 源标题
title: '西安理工大学教务处-' + dic_title[category],
// 源链接
link: rootUrl,
// 源说明
description: `西安理工大学教务处-` + dic_title[category],
// 遍历此前获取的数据
item: await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
if (!item.link.match('zhixing.xaut.edu.cn') && !item.link.match('xinwen.xaut.edu.cn')) {
const res = await got({
method: 'get',
url: item.link,
});
const content = cheerio.load(res.body);
item.description = content('#vsb_content').html();
} else {
item.description = '请在校内或校园VPN内查看内容';
}
return item;
})
)
),
};
};

View File

@ -0,0 +1,5 @@
module.exports = {
'/index/:category?': ['mocusez'],
'/jwc/:category?': ['mocusez'],
'/rsc/:category?': ['mocusez', 'light0926'],
};

23
lib/v2/xaut/radar.js Normal file
View File

@ -0,0 +1,23 @@
module.exports = {
'xaut.edu.cn': {
_name: '西安理工大学',
index: [
{
title: '学校官网',
docs: 'https://docs.rsshub.app/university.html#xi-an-li-gong-da-xue',
},
],
jwc: [
{
title: '教务处',
docs: 'https://docs.rsshub.app/university.html#xi-an-li-gong-da-xue',
},
],
rsc: [
{
title: '人事处',
docs: 'https://docs.rsshub.app/university.html#xi-an-li-gong-da-xue',
},
],
},
};

5
lib/v2/xaut/router.js Normal file
View File

@ -0,0 +1,5 @@
module.exports = function (router) {
router.get('/index/:category?', require('./index'));
router.get('/jwc/:category?', require('./jwc'));
router.get('/rsc/:category?', require('./rsc'));
};

67
lib/v2/xaut/rsc.js Normal file
View File

@ -0,0 +1,67 @@
const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
let category = ctx.params.category;
// 这里的category是个形参
const dic_html = { tzgg: 'tzgg.htm', gzdt: 'gzdt.htm' };
const dic_title = { tzgg: '通知公告', gzdt: '工作动态' };
// 设置默认值
if (dic_title[category] === undefined) {
category = 'tzgg';
}
const response = await got({
method: 'get',
url: 'http://renshichu.xaut.edu.cn/' + dic_html[category],
});
const data = response.body;
const $ = cheerio.load(data);
// 这个列表指通知公告详情列表
const list = $('.vsb-space.n_right .list .cleafix')
.map((_, item) => {
item = $(item);
// 工作动态栏目里有一些是外链,这里做个判断
const a = item.find('.list_wen a').eq(0).attr('href');
const link = a.slice(0, 4) !== 'http' ? 'http://renshichu.xaut.edu.cn/' + a : a;
// 这里jquery比较长引几个中间变量倒是方便阅读但是我还是觉得不需要
const title = item.find('.list_wen a.tit').text();
return {
title,
link,
};
})
.get();
ctx.state.data = {
// 源标题
title: '西安理工大学人事处-' + dic_title[category],
// 源链接
link: 'http://renshichu.xaut.edu.cn',
// 源说明
description: `西安理工大学人事处-` + dic_title[category],
// 遍历此前获取的数据
item: await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
// 下面的if判断是否属于外链使用切片的方式来判断并不优雅先用着吧
if (item.link.slice(0, 16) === 'http://renshichu') {
// 不属于外链
const res = await got({
method: 'get',
url: item.link,
});
const content = cheerio.load(res.body);
item.description = content('.vsb-space form[name]').html();
item.pubDate = parseDate(content('.vsb-space form[name] h3 span:contains(时间)').text().slice(3));
} else {
item.description = '这是一个外链("▔□▔)/("▔□▔)/所以你没法直接看到内容' + item.link;
}
return item;
})
)
),
};
};