feat: 添加南京中医药大学研究生院博士招生RSS支持 && 添加南京鼓楼医院员工版教育培训RSS支持 (#12307)

* 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

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/v2/gxmzu/maintainer.js

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* feat: 添加南京中医药大学研究生院博士招生RSS支持 && 添加南京鼓楼医院员工版教育培训RSS支持

* fix: fix njglyy/radar docs typos

* Update lib/v2/njucm/radar.js

* fix: remove rejectUnauthorized option

* Update lib/v2/njucm/radar.js

---------
This commit is contained in:
Jaya 2023-04-14 23:32:56 +08:00 committed by GitHub
parent 1421d39f39
commit cf1fe23d7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 184 additions and 1 deletions

View File

@ -20,7 +20,7 @@ on:
permissions:
contents: read
concurrency:
group: ${{ github.head_ref }}
cancel-in-progress: true

View File

@ -718,6 +718,12 @@ pageClass: routes
<Route author="nczitzk" example="/cia/foia-annual-report" path="/cia/foia-annual-report"/>
## 南京鼓楼医院
### 员工版教育培训
<Route author="real-jiakai" example="/njglyy/ygbjypx" path="/njglyy/ygbjypx" radar="1" />
## 南京市人民政府
### 信息公开

View File

@ -2246,6 +2246,12 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
</Route>
## 南京中医药大学
### 研究生院博士招生
<Route author="real-jiakai" example="/njucm/grabszs" path="/njucm/grabszs" radar="1" />
## 南开大学
### 南开大学教务处

View File

@ -0,0 +1,3 @@
module.exports = {
'/ygbjypx': ['real-jiakai'],
};

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

@ -0,0 +1,13 @@
module.exports = {
'njglyy.com': {
_name: '南京鼓楼医院',
'.': [
{
title: '员工版教育培训',
docs: 'https://docs.rsshub.app/university.html#nan-jing-gu-lou-yi-yuan-yuan-gong-ban-jiao-yu-pei-xun',
source: ['/ygb/jypx/jypx.aspx', '/'],
target: '/njglyy/ygbjypx',
},
],
},
};

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

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

View File

@ -0,0 +1,50 @@
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, listSelector, itemSelector, titleSelector, contentSelector) {
const response = await got(url);
const $ = cheerio.load(response.data);
const list = $(listSelector)
.toArray()
.map((item) => {
item = $(item);
return {
title: item.find(titleSelector).text(),
link: host + item.find(itemSelector).attr('href'),
};
});
const out = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const response = await got(item.link);
if (response.redirectUrls.length) {
item.link = response.redirectUrls[0];
item.description = '该通知无法直接预览,请点击原文链接↑查看';
} else {
const $ = cheerio.load(response.data);
item.title = $(contentSelector.title).text();
item.description = $(contentSelector.content)
.html()
.replace(/src="\//g, `src="${new URL('.', host).href}`)
.replace(/href="\//g, `href="${new URL('.', host).href}`)
.trim();
const preDate = $(contentSelector.date)
.text()
.match(/(\d{4}-\d{2}-\d{2})/)[1];
item.pubDate = timezone(parseDate(preDate, 'YYYY-MM-DD'), +8);
}
return item;
})
)
);
return out;
}
module.exports = {
getNoticeList,
};

18
lib/v2/njglyy/ygbjypx.js Normal file
View File

@ -0,0 +1,18 @@
const { getNoticeList } = require('./utils');
const url = 'https://njglyy.com/ygb/jypx/jypx.aspx';
const host = 'https://njglyy.com/ygb/jypx/';
module.exports = async (ctx) => {
const out = await getNoticeList(ctx, url, host, '.mtbd-list > dl', 'a', 'dt', {
title: '.detail',
content: '.detail2',
date: 'span:contains("发布时间")',
});
ctx.state.data = {
title: '南京鼓楼医院 -- 员工版教育培训',
link: url,
item: out,
};
};

18
lib/v2/njucm/grabs.js Normal file
View File

@ -0,0 +1,18 @@
const { getNoticeList } = require('./utils');
const url = 'https://gra.njucm.edu.cn/2899/list.htm';
const host = 'https://gra.njucm.edu.cn';
module.exports = async (ctx) => {
const out = await getNoticeList(ctx, url, host, '#wp_news_w3 > table > tbody > tr', 'a', {
title: '.Article_Title',
content: '.Article_Content',
date: '.Article_PublishDate',
});
ctx.state.data = {
title: '南京中医药大学 -- 博士招生',
link: url,
item: out,
};
};

View File

@ -0,0 +1,3 @@
module.exports = {
'/grabszs': ['real-jiakai'],
};

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

@ -0,0 +1,13 @@
module.exports = {
'njucm.edu.cn': {
_name: '南京中医药大学',
lib: [
{
title: '研究生院博士招生',
docs: 'https://docs.rsshub.app/university.html#nan-jing-zhong-yi-yao-da-xue-yan-jiu-sheng-yuan-bo-shi-zhao-sheng',
source: ['/2899/list.htm', '/'],
target: '/njucm/grabszs',
},
],
},
};

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

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

View File

@ -0,0 +1,47 @@
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, listSelector, titleSelector, contentSelector) {
const response = await got(url);
const $ = cheerio.load(response.data);
const list = $(listSelector)
.toArray()
.map((item) => {
item = $(item);
return {
title: item.find(titleSelector).attr('title'),
link: host + item.find(titleSelector).attr('href'),
};
});
const out = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const response = await got(item.link);
if (response.redirectUrls.length) {
item.link = response.redirectUrls[0];
item.description = '该通知无法直接预览,请点击原文链接↑查看';
} else {
const $ = cheerio.load(response.data);
item.title = $(contentSelector.title).text();
item.description = $(contentSelector.content)
.html()
.replace(/src="\//g, `src="${new URL('.', host).href}`)
.replace(/href="\//g, `href="${new URL('.', host).href}`)
.trim();
item.pubDate = timezone(parseDate($(contentSelector.date).text()), +8);
}
return item;
})
)
);
return out;
}
module.exports = {
getNoticeList,
};