feat: 添加广西民族大学RSS支持 && fix: 修复南京晓庄学院RSS日期格式 (#12285)
* feat: add gxmzu utils * fix: test01 * fix: try01 * fix: fix njxzc homepage tzgg date * docs: add gxmzu rss docs support * feat: finish gxmzu rss building * fix: fix njxzc radar's docs * fix: fix docs/university * change gxmzu location in docs/university.md * change gxmzu location in docs/university.md again * a secomd attempt to change gxmzu location in docs/university.md * fix: a third attempt to change gxmzu location in docs/university.md * Update lib/v2/gxmzu/utils/index.js * Update lib/v2/gxmzu/maintainer.js ---------
This commit is contained in:
parent
b2ace34670
commit
8a76f8743b
|
|
@ -1079,6 +1079,16 @@ pageClass: routes
|
|||
|
||||
<Route author="Xiaotouming" example="/gdoujwc" path="/gdoujwc"/>
|
||||
|
||||
## 广西民族大学
|
||||
|
||||
### 研究生院招生公告
|
||||
|
||||
<Route author="real-jiakai" example="/gxmzu/yjszsgg" path="/gxmzu/yjszsgg" radar="1" />
|
||||
|
||||
### 人工智能学院通知公告
|
||||
|
||||
<Route author="real-jiakai" example="/gxmzu/aitzgg" path="/gxmzu/aitzgg" radar="1" />
|
||||
|
||||
## 广州大学
|
||||
|
||||
## 广州大学研招网通知公告
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
const { getNoticeList } = require('./utils');
|
||||
|
||||
const url = 'https://ai.gxmzu.edu.cn/index/tzgg.htm';
|
||||
const host = 'https://ai.gxmzu.edu.cn';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const out = await getNoticeList(ctx, url, host, 'a', '.timestyle55267', {
|
||||
title: '.titlestyle55269',
|
||||
content: '#vsb_content',
|
||||
date: '.timestyle55269',
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: '广西民族大学人工智能学院 -- 通知公告',
|
||||
link: url,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = {
|
||||
'/aitzgg': ['real-jiakai'],
|
||||
'/yjszsgg': ['real-jiakai'],
|
||||
};
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
module.exports = {
|
||||
'gxmzu.edu.cn': {
|
||||
_name: '广西民族大学',
|
||||
ai: [
|
||||
{
|
||||
title: '人工智能学院通知公告',
|
||||
docs: 'https://docs.rsshub.app/university.html#guang-xi-min-zu-da-xue-ren-gong-zhi-neng-xue-yuan-tong-zhi-gong-gao',
|
||||
source: ['/index/tzgg.htm', '/'],
|
||||
target: '/gxmzu/aitzgg',
|
||||
},
|
||||
],
|
||||
yjs: [
|
||||
{
|
||||
title: '研究生院招生公告',
|
||||
docs: 'https://docs.rsshub.app/university.html#guang-xi-min-zu-da-xue-yan-jiu-sheng-yuan-zhao-sheng-gong-gao',
|
||||
source: ['/tzgg/zsgg.htm', '/'],
|
||||
target: '/gxmzu/yjszsgg',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = (router) => {
|
||||
router.get('/aitzgg', require('./ai'));
|
||||
router.get('/yjszsgg', require('./yjs'));
|
||||
};
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
async function getNoticeList(ctx, url, host, titleSelector, dateSelector, contentSelector) {
|
||||
const response = await got({ url, https: { rejectUnauthorized: false } });
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $(`tr[height=20]`)
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.find(titleSelector).attr('title'),
|
||||
link: new URL(item.find(titleSelector).attr('href'), host).href,
|
||||
pubDate: timezone(parseDate(item.find(dateSelector).text().trim(), 'YYYY-MM-DD'), +8),
|
||||
};
|
||||
});
|
||||
|
||||
const out = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
if (item.link.includes('.jsp')) {
|
||||
item.description = '该通知无法直接预览,请点击原文链接↑查看';
|
||||
} else {
|
||||
const response = await got({ url: item.link, https: { rejectUnauthorized: false } });
|
||||
if (response.redirectUrls.length) {
|
||||
item.link = response.redirectUrls[0];
|
||||
item.description = '该通知无法直接预览,请点击原文链接↑查看';
|
||||
} else {
|
||||
const $ = cheerio.load(response.data);
|
||||
item.title = $(contentSelector.title).text();
|
||||
const hasEmbeddedPDFScript = $('script:contains("showVsbpdfIframe")').length > 0;
|
||||
|
||||
if (hasEmbeddedPDFScript) {
|
||||
item.description = '该通知无法直接预览,请点击原文链接↑查看';
|
||||
} else {
|
||||
item.description = $(contentSelector.content).html();
|
||||
}
|
||||
const preDate = $(contentSelector.date).text().replace(/年|月/g, '-').replace(/日/g, '');
|
||||
item.pubDate = timezone(parseDate(preDate), +8);
|
||||
}
|
||||
}
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getNoticeList,
|
||||
};
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
const { getNoticeList } = require('./utils');
|
||||
|
||||
const url = 'https://yjs.gxmzu.edu.cn/tzgg/zsgg.htm';
|
||||
const host = 'https://yjs.gxmzu.edu.cn';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const out = await getNoticeList(ctx, url, host, 'a', '.timestyle55267', {
|
||||
title: '.titlestyle55269',
|
||||
content: '#vsb_content',
|
||||
date: '.timestyle55269',
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: '广西民族大学研究生院 -- 招生公告',
|
||||
link: url,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
|
|
@ -4,7 +4,7 @@ module.exports = {
|
|||
lib: [
|
||||
{
|
||||
title: '图书馆通知公告',
|
||||
docs: 'https://docs.rsshub.app/university.html#nan-jing-xiao-zhuang-xue-yuan-guan-wang-tong-zhi-gong-gao',
|
||||
docs: 'https://docs.rsshub.app/university.html#nan-jing-xiao-zhuang-xue-yuan-tu-shu-guan-tong-zhi-gong-gao',
|
||||
source: ['/pxyhd/list.htm', '/'],
|
||||
target: '/njxzc/libtzgg',
|
||||
},
|
||||
|
|
@ -12,7 +12,7 @@ module.exports = {
|
|||
www: [
|
||||
{
|
||||
title: '通知公告',
|
||||
docs: 'https://docs.rsshub.app/university.html#nan-jing-xiao-zhuang-xue-yuan-tu-shu-guan-tong-zhi-gong-gao',
|
||||
docs: 'https://docs.rsshub.app/university.html#nan-jing-xiao-zhuang-xue-yuan-guan-wang-tong-zhi-gong-gao',
|
||||
source: ['/89/list.htm', '/'],
|
||||
target: '/njxzc/tzgg',
|
||||
},
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ async function getNoticeList(ctx, url, host, titleSelector, dateSelector, conten
|
|||
.replace(/src="\//g, `src="${new URL('.', host).href}`)
|
||||
.replace(/href="\//g, `href="${new URL('.', host).href}`)
|
||||
.trim();
|
||||
item.pubDate = timezone(parseDate($(contentSelector.date).text().replace('编辑:', '').replace('发布日期:', '')), +8);
|
||||
item.pubDate = timezone(parseDate($(contentSelector.date).text().replace('编辑:', '').replace('发布日期:', '').replace('发布时间:', '')), +8);
|
||||
}
|
||||
return item;
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue