feat(route): add 南京大学基建处/本科迎新 (#10305)

* feat(route): add 南京大学基建处/本科迎新

* feat(route): add 南京大学基建处/本科迎新

* fix: sort router
This commit is contained in:
XR-Y
2022-07-25 00:23:40 +08:00
committed by GitHub
parent 0e0681fbc8
commit c105ab9a19
6 changed files with 126 additions and 16 deletions
+8
View File
@@ -1721,6 +1721,14 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
</Route>
### 基建处
<Route author="ret-1" example="/nju/jjc" path="/nju/jjc" />
### 本科迎新
<Route author="ret-1" example="/nju/admission" path="/nju/admission" />
## 南京工程学院
### 南京工程学院通知公告
+41
View File
@@ -0,0 +1,41 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const category_dict = {
tzgg: '通知公告'
};
const items = await Promise.all(
Object.keys(category_dict).map(async () => {
const response = await got(`https://admission.nju.edu.cn/tzgg`);
const data = response.data;
const $ = cheerio.load(data);
let script = $('ul').find('script');
script = script['1'].children[0].data;
const start = script.indexOf('[');
const end = script.lastIndexOf(']');
const t = JSON.parse(script.substring(start, end + 1));
// only read first page
return Promise.resolve(
t[0].infolist.map((item) => ({
title: item.title,
description: item.summary,
link: item.url,
author: item.username,
pubDate: parseDate(item.releasetime, 'x'),
}))
);
})
);
ctx.state.data = {
title: '本科迎新-通知公告',
link: 'https://admission.nju.edu.cn/tzgg',
item: items[0],
};
};
+41
View File
@@ -0,0 +1,41 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const timezone = require("@/utils/timezone");
module.exports = async (ctx) => {
const category_dict = {
cgxx: '采购信息',
cjgg: '成交公告',
cfgg: '处罚公告',
};
const items = await Promise.all(
Object.keys(category_dict).map(async (c) => {
const response = await got(`https://jjc.nju.edu.cn/${c}/list.htm`);
const data = response.data;
const $ = cheerio.load(data);
const list = $('#wp_news_w6').children().children().children();
// only read first page
return Promise.resolve(
list.map((index, item) => {
item = $(item);
return {
title: item.find('a').attr('title'),
description: item.find('a').first().text(),
link: 'https://jjc.nju.edu.cn' + item.find('a').attr('href'),
pubDate: timezone(parseDate(item.find('td').last().text(), 'YYYY-MM-DD'), +8),
category: category_dict[c],
};})
);
})
);
ctx.state.data = {
title: `南京大学基建处`,
link: 'https://jjc.nju.edu.cn/main.htm',
item: [...items[0], ...items[1], ...items[2]],
};
};
+4 -2
View File
@@ -1,8 +1,10 @@
module.exports = {
'/jw/:type': ['ret-1'],
'/admission': ['ret-1'],
'/gra': ['ret-1'],
'/jjc': ['ret-1'],
'/jw/:type': ['ret-1'],
'/rczp/:type': ['ret-1'],
'/scit/:type': ['ret-1'],
'/zcc': ['ret-1'],
'/zbb/:type': ['ret-1'],
'/zcc': ['ret-1'],
};
+29 -13
View File
@@ -1,12 +1,12 @@
module.exports = {
'nju.edu.cn': {
_name: '南京大学',
jw: [
admission: [
{
title: '本科生院',
docs: 'https://docs.rsshub.app/university.html#nan-jing-da-xue-ben-ke-sheng-yuan',
source: ['/'],
target: '/nju/jw/:type',
title: '本科迎新',
docs: 'https://docs.rsshub.app/university.html#nan-jing-da-xue-ben-ke-ying-xin',
source: ['/tzgg/index.html', '/'],
target: '/nju/admission',
},
],
grawww: [
@@ -17,6 +17,22 @@ module.exports = {
target: '/nju/gra',
},
],
jjc: [
{
title: '基建处',
docs: 'https://docs.rsshub.app/university.html#nan-jing-da-xue-ji-jian-chu',
source: ['/main.htm', '/'],
target: '/nju/jjc',
},
],
jw: [
{
title: '本科生院',
docs: 'https://docs.rsshub.app/university.html#nan-jing-da-xue-ben-ke-sheng-yuan',
source: ['/'],
target: '/nju/jw/:type',
},
],
rczp: [
{
title: '人才招聘网',
@@ -33,14 +49,6 @@ module.exports = {
target: '/nju/scit/:type',
},
],
zcc: [
{
title: '资产管理处',
docs: 'https://docs.rsshub.app/university.html#nan-jing-da-xue-zi-chan-guan-li-chu',
source: ['/'],
target: '/nju/zcc',
},
],
zbb: [
{
title: '招标办公室',
@@ -49,5 +57,13 @@ module.exports = {
target: '/nju/zbb/:type',
},
],
zcc: [
{
title: '资产管理处',
docs: 'https://docs.rsshub.app/university.html#nan-jing-da-xue-zi-chan-guan-li-chu',
source: ['/'],
target: '/nju/zcc',
},
],
},
};
+3 -1
View File
@@ -1,8 +1,10 @@
module.exports = function (router) {
router.get('/admission', require('./admission'));
router.get('/jjc', require('./jjc'));
router.get('/jw/:type', require('./jw'));
router.get('/gra', require('./gra'));
router.get('/rczp/:type', require('./rczp'));
router.get('/scit/:type', require('./scit'));
router.get('/zcc', require('./zcc'));
router.get('/zbb/:type', require('./zbb'));
router.get('/zcc', require('./zcc'));
};