fix(route): 南京信息工程大学研究生院学科建设处 (#10464)

* fix(route): 南京信息工程大学研究生院学科建设处

* fix: deprecated url resolve

* update lib/v2/nuist/yjs.js

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

* fix: typo
This commit is contained in:
Ethan Shen 2022-08-16 00:01:36 +08:00 committed by GitHub
parent ac77cb202f
commit 28c61bf84a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 497 additions and 441 deletions

View File

@ -1963,7 +1963,7 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
### 南信大信息公告栏
<Route author="gylidian" example="/nuist/bulletin/791" path="/nuist/bulletin/:category?" :paramsDesc="['默认为 `791`']">
<Route author="gylidian" example="/nuist/bulletin/791" path="/nuist/bulletin/:category?" :paramsDesc="['默认为 `791`']" radar="1" rssbud="1">
| 全部 | 文件公告 | 学术报告 | 招标信息 | 会议通知 | 党政事务 | 组织人事 |
| --- | ---- | ----- | ---- | ---- | ---- | ---- |
@ -1983,35 +1983,41 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
### NUIST CS南信大计软院
<Route author="gylidian" example="/nuist/scs/2242" path="/nuist/scs/:category?" :paramsDesc="['默认为 `2242`']">
<Route author="gylidian" example="/nuist/scs/xwkx" path="/nuist/scs/:category?" :paramsDesc="['默认为新闻快讯']" radar="1" rssbud="1">
| 学院新闻 | 学生工作 | 通知公告 | 教务通知 | 科研动态 | 招生就业 |
| ---- | ---- | ---- | ---- | ---- | ---- |
| 2242 | 2237 | 2245 | 2246 | 2243 | 2244 |
| 新闻快讯 | 通知公告 | 教务信息 | 科研动态 | 学子风采 |
| ---- | ---- | ---- | ---- | ---- |
| xwkx | tzgg | jwxx | kydt | xzfc |
</Route>
### 南信大本科教学信息网
### 教务处
<Route author="gylidian" example="/nuist/jwc/1" path="/nuist/jwc/:category?" :paramsDesc="['默认为 `1`']">
<Route author="gylidian" example="/nuist/jwc/jxyw" path="/nuist/jwc/:category?" :paramsDesc="['默认为教学要闻']" radar="1" rssbud="1">
| 通知公告 | 教学新闻 | 规章制度 | 教学研究 | 教务管理 | 考试中心 |
| ---- | ---- | ---- | ---- | ---- | ---- |
| 1 | 2 | 4 | 5 | 6 | 7 |
| 教材建设 | 实践教学 | 三百工程 | 创新创业 | 规章制度 | 业务办理 |
| ---- | ---- | ---- | ---- | ---- | ---- |
| 8 | 9 | 56 | 60 | 62 | 43 |
| 教学要闻 | 学院教学 | 教务管理 | 教学研究 | 教务管理 | 教材建设 | 考试中心 |
| ---- | ---- | ---- | ---- | ---- | ---- | ---- |
| jxyw | xyjx | jwgl | jxyj | sjjx | jcjs | kszx |
</Route>
### 南信大研究生院学科建设处
### 研究生院学科建设处
<Route author="gylidian" example="/nuist/yjs/11" path="/nuist/yjs/:category?" :paramsDesc="['默认为 `11`']">
<Route author="gylidian nczitzk" example="/nuist/yjs/index/tzgg" path="/nuist/yjs/:path+" :paramsDesc="['默认为通知公告']">
| 招生工作 | 培养工作 | 学位工作 | 学生工作 | 就业工作 | 国际合作 | 文件下载 | 工作动态 | 通知公告 |
| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- |
| 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
::: tip 提示
路径字段处填写的是对应南京信息工程大学研究生院学科建设处分类页网址中介于 **<https://yjs.nuist.edu.cn/>** 和 **.htm** 中间的一段。
如 [南京信息工程大学研究生院学科建设处工作动态](https://yjs.nuist.edu.cn/index/gzdt.htm) 的网址为 <https://yjs.nuist.edu.cn/index/gzdt.htm> 其中介于 **<https://yjs.nuist.edu.cn/>** 和 **.htm** 中间的一段为 `index/gzdt`。可以得到路由为 [`/nuist/yjs/index/gzdt`](https://rsshub.app/nuist/yjs/index/gzdt)
:::
以下为部分分类:
| 工作动态 | 通知公告 | 招生工作 | 培养与学位 | 学生工作 |
| ---------- | ---------- | --------- | --------- | ---------- |
| index/gzdt | index/tzgg | zsgz/sszs | xwgz/xwtz | xsgz1/xzfc |
</Route>
@ -2021,37 +2027,27 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
### NUIST ESE南信大环科院
<Route author="gylidian" example="/nuist/sese/11" path="/nuist/sese/:category?" :paramsDesc="['默认为 `11`']">
<Route author="gylidian" example="/nuist/sese/tzgg1" path="/nuist/sese/:category?" :paramsDesc="['默认为通知公告']" radar="1" rssbud="1">
| 通知公告 | 新闻快讯 | 学术动态 | 学生工作 | 研究生教育 | 本科教育 |
| ---- | ---- | ---- | ---- | ----- | ---- |
| 11 | 10 | 12 | 6 | 4 | 3 |
| 通知公告 | 新闻快讯 | 学术动态 | 学生工作 | 研究生教育 | 本科教育 |
| ----- | ---- | ----- | ----- | ------ | ----- |
| tzgg1 | xwkx | xsdt1 | xsgz1 | yjsjy1 | bkjy1 |
</Route>
### NUIST AS南信大大气科学学院
<Route author="gylidian" example="/nuist/cas/12" path="/nuist/cas/:category?" :paramsDesc="['默认为 `12`']">
<Route author="gylidian" example="/nuist/cas/xxgg" path="/nuist/cas/:category?" :paramsDesc="['默认为信息公告']" radar="1" rssbud="1">
| 信息公告 | 新闻快讯 | 科学研究 | 网上公示 | 本科教育 | 研究生教育 |
| ---- | ---- | ---- | ---- | ---- | ----- |
| 12 | 11 | 3 | 110 | 4 | 5 |
| xxgg | xwkx | kxyj | wsgs | bkjy | yjsjy |
</Route>
### 南京信息工程大学图书馆
<Route author="gylidian" example="/nuist/lib" path="/nuist/library/lib">
::: tip 提示
学校图书馆官网提供了[新书通报](http://lib2.nuist.edu.cn/newbook/newbook_cls_browse.php)的订阅
由于图书馆通知频率过低 (故只提供 3 条),有待将其和 **网络信息中心**、**基建处**、**总务处** 等的通知整合起来
:::
</Route>
<Route author="gylidian" example="/nuist/lib" path="/nuist/library/lib" />
## 南京邮电大学

View File

@ -614,14 +614,14 @@ router.get('/cqu/sci/:category', lazyloadRouteHandler('./routes/universities/cqu
router.get('/cqu/net/:category', lazyloadRouteHandler('./routes/universities/cqu/net/info'));
// 南京信息工程大学
router.get('/nuist/bulletin/:category?', lazyloadRouteHandler('./routes/universities/nuist/bulletin'));
router.get('/nuist/jwc/:category?', lazyloadRouteHandler('./routes/universities/nuist/jwc'));
router.get('/nuist/yjs/:category?', lazyloadRouteHandler('./routes/universities/nuist/yjs'));
router.get('/nuist/xgc', lazyloadRouteHandler('./routes/universities/nuist/xgc'));
router.get('/nuist/scs/:category?', lazyloadRouteHandler('./routes/universities/nuist/scs'));
router.get('/nuist/lib', lazyloadRouteHandler('./routes/universities/nuist/library/lib'));
router.get('/nuist/sese/:category?', lazyloadRouteHandler('./routes/universities/nuist/sese'));
router.get('/nuist/cas/:category?', lazyloadRouteHandler('./routes/universities/nuist/cas'));
// router.get('/nuist/bulletin/:category?', lazyloadRouteHandler('./routes/universities/nuist/bulletin'));
// router.get('/nuist/jwc/:category?', lazyloadRouteHandler('./routes/universities/nuist/jwc'));
// router.get('/nuist/yjs/:category?', lazyloadRouteHandler('./routes/universities/nuist/yjs'));
// router.get('/nuist/xgc', lazyloadRouteHandler('./routes/universities/nuist/xgc'));
// router.get('/nuist/scs/:category?', lazyloadRouteHandler('./routes/universities/nuist/scs'));
// router.get('/nuist/lib', lazyloadRouteHandler('./routes/universities/nuist/library/lib'));
// router.get('/nuist/sese/:category?', lazyloadRouteHandler('./routes/universities/nuist/sese'));
// router.get('/nuist/cas/:category?', lazyloadRouteHandler('./routes/universities/nuist/cas'));
// 成都信息工程大学
router.get('/cuit/cxxww/:type?', lazyloadRouteHandler('./routes/universities/cuit/cxxww'));

View File

@ -1,60 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const url = require('url');
const baseTitle = 'NUIST AS南信大大气科学学院';
const baseUrl = 'http://cas.nuist.edu.cn';
const map = {
12: '信息公告',
11: '新闻快讯',
3: '科学研究',
110: '网上公示',
4: '本科教育',
5: '研究生教育',
};
module.exports = async (ctx) => {
const category = map.hasOwnProperty(ctx.params.category) ? ctx.params.category : 12;
const link = baseUrl + '/Show.aspx?CI=' + category;
const response = await got.get(link);
const $ = cheerio.load(response.data);
const list = $('#ctl00_ctl00_body_NewsList')
.find('tr.gridline')
.slice(0, 6)
.map((index, item) => {
const td = $(item).find('td.gridline').slice(0, 10);
return {
title: $(item).find('.Title').text().trim(),
link: url.resolve(baseUrl, $(item).find('.Title').attr('href')),
category: td.eq(1).text().trim(),
pubDate: new Date(td.eq(2).text().replace('[', '').replace(']', '')).toUTCString(),
};
})
.get();
const items = await Promise.all(
[...list].map(async (item) => {
const cache = await ctx.cache.get(item.link);
if (cache) {
return JSON.parse(cache);
}
const response = await got.get(item.link);
const $ = cheerio.load(response.data);
const article = $('#ctl00_ctl00_body_lmnr');
item.author = article.find('.zzxx').text().split(' ')[0].trimRight().replace('作者:', '');
item.description = article.find('.xwco').html();
ctx.cache.set(item.link, JSON.stringify(item));
return item;
})
);
ctx.state.data = {
title: baseTitle + ':' + map[category],
link,
item: items.filter((x) => x),
};
};

View File

@ -1,66 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const url = require('url');
const baseTitle = '南信大本科教学信息网';
const baseUrl = 'http://jwc.nuist.edu.cn';
const map = {
1: '通知公告',
2: '教学新闻',
4: '规章制度',
5: '教学研究',
6: '教务管理',
7: '考试中心',
8: '教材建设',
9: '实践教学',
56: '三百工程',
60: '创新创业',
62: '规章制度',
43: '业务办理',
};
module.exports = async (ctx) => {
const category = map.hasOwnProperty(ctx.params.category) ? ctx.params.category : 1;
const link = baseUrl + '/Show.aspx?CI=' + category;
const response = await got.get(link);
const $ = cheerio.load(response.data);
const list = $('#ctl00_ctl00_mainbody_rightbody_NewsList')
.find('.gridline')
.slice(0, 6)
.map((index, item) => {
const td = $(item).find('td');
return {
title: td.eq(0).text(),
link: url.resolve(baseUrl, td.eq(0).find('a').attr('href')),
pubDate: new Date(td.eq(2).text()).toUTCString(),
};
})
.get();
const items = await Promise.all(
[...list].map(async (item) => {
const cache = await ctx.cache.get(item.link);
if (cache) {
return JSON.parse(cache);
}
const response = await got.get(item.link);
const $ = cheerio.load(response.data);
const article = $('#ctl00_ctl00_mainbody_rightbody_lmnr');
item.author = article.find('.zzxx').text().split(' ')[0].trimRight();
item.description = article.find('.xwco').html();
item.category = map[category];
ctx.cache.set(item.link, JSON.stringify(item));
return item;
})
);
ctx.state.data = {
title: baseTitle + ':' + map[category],
link,
item: items.filter((x) => x),
};
};

View File

@ -1,32 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const url = require('url');
const baseTitle = '南京信息工程大学图书馆通知';
const baseUrl = 'http://lib.nuist.edu.cn';
module.exports = async (ctx) => {
const link = baseUrl + '/list.php?fid=7';
const response = await got.get(link);
const $ = cheerio.load(response.data);
const list = $('.lines_chen').slice(0, 3);
ctx.state.data = {
title: baseTitle,
link,
item: list
.map((_, item) => {
item = $(item);
return {
title: item.children('a').first().text(),
description: item.find('.neirong1').text(),
category: '通知',
pubDate: new Date(item.children('p').children('span').first().text().replace('发布时间:', '')).toUTCString(),
link: url.resolve(baseUrl, item.children('a').first().attr('href')),
};
})
.get(),
};
};

View File

@ -1,60 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const url = require('url');
const baseTitle = 'NUIST CS南信大计软院';
const baseUrl = 'http://scs.nuist.edu.cn';
const map = {
2242: '学院新闻',
2237: '学生工作',
2245: '通知公告',
2246: '教务通知',
2243: '科研动态',
2244: '招生就业',
};
module.exports = async (ctx) => {
const category = map.hasOwnProperty(ctx.params.category) ? ctx.params.category : 2242;
const link = baseUrl + '/' + category + '/list.htm';
const response = await got.get(link);
const $ = cheerio.load(response.data);
const list = $('#wp_news_w6')
.find('.list_item')
.slice(0, 8)
.map((index, item) => {
item = $(item);
return {
title: item.find('.Article_Title').text(),
link: url.resolve(baseUrl, item.find('.Article_Title a').attr('href')),
pubDate: new Date(item.find('.Article_PublishDate').text()).toUTCString(),
};
})
.get();
const items = await Promise.all(
[...list].map(async (item) => {
const cache = await ctx.cache.get(item.link);
if (cache) {
return JSON.parse(cache);
}
const response = await got.get(item.link);
const $ = cheerio.load(response.data);
item.author = $('.arti_publisher').text().replace('发布者:', '');
item.description = $('.wp_articlecontent').html();
item.category = map[category];
ctx.cache.set(item.link, JSON.stringify(item));
return item;
})
);
ctx.state.data = {
title: baseTitle + ':' + map[category],
link,
item: items.filter((x) => x),
};
};

View File

@ -1,60 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const url = require('url');
const baseTitle = 'NUIST ESE南信大环科院';
const baseUrl = 'http://sese.nuist.edu.cn';
const map = {
11: '通知公告',
10: '新闻快讯',
12: '学术动态',
6: '学生工作',
4: '研究生教育',
3: '本科教育',
};
module.exports = async (ctx) => {
const category = map.hasOwnProperty(ctx.params.category) ? ctx.params.category : 11;
const link = baseUrl + '/Showbksjy.aspx?CI=' + category;
const response = await got.get(link);
const $ = cheerio.load(response.data);
const list = $('#ctl00_ctl00_mainbody_rightbody_listcontent_NewsList')
.find('.gridline')
.slice(0, 6)
.map((index, item) => {
const a = $(item).find('.gridlinediv a');
return {
title: a.eq(1).text(),
link: url.resolve(baseUrl, a.eq(1).attr('href')),
category: a.first().text(),
pubDate: new Date($(item).find('.gridlinedate').text().match(/\d+/g)).toUTCString(),
};
})
.get();
const items = await Promise.all(
[...list].map(async (item) => {
const cache = await ctx.cache.get(item.link);
if (cache) {
return JSON.parse(cache);
}
const response = await got.get(item.link);
const $ = cheerio.load(response.data);
const article = $('#ctl00_ctl00_mainbody_rightbody_listcontent_lmnr');
item.author = article.find('.zzxx span').first().text();
item.description = article.find('.xwco').html();
ctx.cache.set(item.link, JSON.stringify(item));
return item;
})
);
ctx.state.data = {
title: baseTitle + ':' + map[category],
link,
item: items.filter((x) => x),
};
};

View File

@ -1,48 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const url = require('url');
const baseTitle = '南信大学生工作处';
const baseUrl = 'http://xgc.nuist.edu.cn';
module.exports = async (ctx) => {
const link = baseUrl + '/419/list.htm';
const response = await got.get(link);
const $ = cheerio.load(response.data);
const list = $('.Article_Title a')
.slice(0, 6)
.map((index, item) => {
item = $(item);
return {
title: item.text(),
link: url.resolve(baseUrl, item.attr('href')),
};
})
.get();
const items = await Promise.all(
[...list].map(async (item) => {
const cache = await ctx.cache.get(item.link);
if (cache) {
return JSON.parse(cache);
}
const response = await got.get(item.link);
const $ = cheerio.load(response.data);
const articleInfo = $('.arti_metas');
item.author = articleInfo.find('.arti_publisher').text().replace('作者:', '');
item.pubDate = new Date(articleInfo.find('.arti_update').text().match(/\d+/g)).toUTCString();
item.description = $('.wp_articlecontent ').html();
ctx.cache.set(item.link, JSON.stringify(item));
return item;
})
);
ctx.state.data = {
title: baseTitle,
link,
item: items.filter((x) => x),
};
};

View File

@ -1,63 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const url = require('url');
const baseTitle = '南信大研究生院学科建设处';
const baseUrl = 'http://yjs.nuist.edu.cn';
const map = {
3: '招生工作',
4: '培养工作',
5: '学位工作',
6: '学生工作',
7: '就业工作',
8: '国际合作',
9: '文件下载',
10: '工作动态',
11: '通知公告',
};
module.exports = async (ctx) => {
const category = map.hasOwnProperty(ctx.params.category) ? ctx.params.category : 11;
const link = baseUrl + '/Show.aspx?CI=' + category;
const response = await got.get(link);
const $ = cheerio.load(response.data);
const list = $('#ctl00_ctl00_ContentPlaceHolder2_mainbody_rightbody_listcontent_NewsList')
.find('.gridline')
.slice(0, 6)
.map((index, item) => {
item = $(item);
return {
title: item.find('.Title').text(),
link: url.resolve(baseUrl, item.find('.Title').attr('href')),
pubDate: new Date(item.find('.gridlinedate').text().match(/\d+/g)).toUTCString(),
};
})
.get();
const items = await Promise.all(
[...list].map(async (item) => {
const cache = await ctx.cache.get(item.link);
if (cache) {
return JSON.parse(cache);
}
const response = await got.get(item.link);
const $ = cheerio.load(response.data);
const article = $('#ctl00_ctl00_ContentPlaceHolder2_mainbody_rightbody_listcontent_lmnr');
item.author = article.find('.zzxx span').eq(0).text();
item.description = article.find('.xwco').html();
item.category = map[category];
ctx.cache.set(item.link, JSON.stringify(item));
return item;
})
);
ctx.state.data = {
title: baseTitle + ':' + map[category],
link,
item: items.filter((x) => x),
};
};

View File

@ -1,6 +1,6 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const url = require('url');
const { parseDate } = require('@/utils/parse-date');
const baseTitle = '南信大信息公告栏';
const baseUrl = 'https://bulletin.nuist.edu.cn';
@ -25,9 +25,9 @@ module.exports = async (ctx) => {
const category = map.hasOwnProperty(ctx.params.category) ? ctx.params.category : '791';
const link = `${baseUrl}/${category}/list.htm`;
const response = await got.get(link);
const response = await got(link);
const $ = cheerio.load(response.data);
const list = $('.news_list').find('.news').slice(0, 10);
const list = $('.news_list').find('.news');
ctx.state.data = {
title: baseTitle + (category === '791' ? '' : ':' + map[category]),
@ -42,18 +42,18 @@ module.exports = async (ctx) => {
title: itemXsTitle.text(),
author: item.find('.xs_bgr').text(),
category: '学术报告',
pubDate: new Date(item.find('.xs_date').text()).toUTCString(),
link: url.resolve(baseUrl, itemXsTitle.attr('href')),
pubDate: parseDate(item.find('.xs_date').text()),
link: new URL(itemXsTitle.attr('href'), baseUrl).href,
};
}
const itemTitle = item.find('.news_title');
return {
title: [itemTitle.find('.zdtb img').length > 0 ? '[顶]' : '', itemTitle.find('.btt').text()].join(''),
title: [itemTitle.find('.zdtb img').length > 0 ? '[顶]' : '', itemTitle.find('.btt').text()].join(' '),
author: item.find('.news_org').text(),
category: itemTitle.find('.wjj').text(),
pubDate: new Date(item.find('.news_date').text()).toUTCString(),
link: url.resolve(baseUrl, itemTitle.find('.btt a').attr('href')),
pubDate: parseDate(item.find('.news_date').text()),
link: new URL(itemTitle.find('.btt a').attr('href'), baseUrl).href,
};
})
.get(),

71
lib/v2/nuist/cas.js Normal file
View File

@ -0,0 +1,71 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const timezone = require('@/utils/timezone');
const baseTitle = 'NUIST AS南信大大气科学学院';
const baseUrl = 'https://cas.nuist.edu.cn';
module.exports = async (ctx) => {
const { category = 'xxgg' } = ctx.params;
const link = `${baseUrl}/index/${category}.htm`;
const response = await got(link);
const $ = cheerio.load(response.data);
const list = $('#ctl00_ctl00_body_NewsList')
.find('tr.gridline')
.toArray()
.map((item) => {
item = $(item);
return {
title: item.find('.Title').text().trim(),
link: new URL(item.find('.Title').attr('href'), baseUrl).href,
pubDate: parseDate(
item
.find('td')
.eq(2)
.text()
.replace(/[[\]]+/g, ''),
'YYYY.MM.DD'
),
};
});
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
let response;
try {
response = await got(item.link);
const $ = cheerio.load(response.data);
const authorMatch = $('.zzxx')
.text()
.match(/作者:(.*) 发布时间/);
item.author = authorMatch ? authorMatch[1].trim() : null;
item.pubDate = timezone(
parseDate(
item
.find('.zzxx')
.text()
.match(/发布时间:(\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2})/)[1]
),
+8
);
item.description = $('#vsb_content').html();
} catch (e) {
// intranet
}
return item;
})
)
);
ctx.state.data = {
title: baseTitle + '' + $('.dqlm').find('a').eq(1).text(),
description: $('meta[name=description]').attr('content'),
link,
item: items,
};
};

43
lib/v2/nuist/jwc.js Normal file
View File

@ -0,0 +1,43 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const baseTitle = '南京信息工程大学-教务处';
const baseUrl = 'https://jwc.nuist.edu.cn';
module.exports = async (ctx) => {
const { category = 'jxyw' } = ctx.params;
const link = `${baseUrl}/${category === 'jxyw' || category === 'xyjx' ? 'index' : 'xxtz'}/${category}.htm`;
const response = await got(link);
const $ = cheerio.load(response.data);
const list = $('.main_list ul li')
.toArray()
.map((item) => {
item = $(item);
return {
title: item.find('a').contents().first().text(),
link: new URL(item.find('a').attr('href'), baseUrl).href,
pubDate: parseDate(item.find('.date').text()),
};
});
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = cheerio.load(response.data);
item.description = $('#vsb_content').html();
return item;
})
)
);
ctx.state.data = {
title: baseTitle + '' + $('.dqwz').find('a').eq(1).text(),
link,
item: items,
};
};

View File

@ -0,0 +1,43 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const baseTitle = '南京信息工程大学图书馆通知';
const baseUrl = 'https://lib.nuist.edu.cn';
module.exports = async (ctx) => {
const link = baseUrl + '/index/tzgg.htm';
const response = await got(link);
const $ = cheerio.load(response.data);
const list = $('.list2 li')
.toArray()
.map((item) => {
item = $(item);
return {
title: item.find('a').attr('title'),
category: '通知',
link: new URL(item.find('a').attr('href'), link).href,
};
});
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = cheerio.load(response.data);
item.description = $('#vsb_content').html();
item.pubDate = parseDate($('.date').find('span').eq(0).text(), 'YYYY年MM月DD日');
return item;
})
)
);
ctx.state.data = {
title: baseTitle,
link,
item: items,
};
};

View File

@ -0,0 +1,10 @@
module.exports = {
'/bulletin/:category?': ['gylidian'],
'/cas/:category?': ['gylidian'],
'/jwc/:category?': ['gylidian'],
'/lib': ['gylidian'],
'/scs/:category?': ['gylidian'],
'/sese/:category?': ['gylidian'],
'/xgc': ['gylidian'],
'/yjs/:path+': ['gylidian', 'nczitzk'],
};

69
lib/v2/nuist/radar.js Normal file
View File

@ -0,0 +1,69 @@
module.exports = {
'nuist.edu.cn': {
_name: '南京信息工程大学',
bulletin: [
{
title: '信息公告栏',
docs: 'https://docs.rsshub.app/university.html#nan-jing-xin-xi-gong-cheng-da-xue',
source: ['/:category/list.htm'],
target: '/nuist/bulletin/:category',
},
],
cas: [
{
title: '大气科学学院',
docs: 'https://docs.rsshub.app/university.html#nan-jing-xin-xi-gong-cheng-da-xue',
source: ['/index/:category'],
target: (params) => `/nuist/cas/${params.category.replace('.htm', '')}`,
},
],
jwc: [
{
title: '教务处',
docs: 'https://docs.rsshub.app/university.html#nan-jing-xin-xi-gong-cheng-da-xue',
source: ['/index/:category', '/xxtz/:category'],
target: (params) => `/nuist/jwc/${params.category.replace('.htm', '')}`,
},
],
lib: [
{
title: '图书馆',
docs: 'https://docs.rsshub.app/university.html#nan-jing-xin-xi-gong-cheng-da-xue',
source: ['/', '/index/tzgg.htm'],
target: '/nuist/lib',
},
],
scs: [
{
title: '计软院',
docs: 'https://docs.rsshub.app/university.html#nan-jing-xin-xi-gong-cheng-da-xue',
source: ['/:category/list.htm'],
target: '/nuist/scs/:category',
},
],
sese: [
{
title: '环科院',
docs: 'https://docs.rsshub.app/university.html#nan-jing-xin-xi-gong-cheng-da-xue',
source: ['/:category'],
target: (params) => `/nuist/sese/${params.category.replace('.htm', '')}`,
},
],
xgc: [
{
title: '学生工作处',
docs: 'https://docs.rsshub.app/university.html#nan-jing-xin-xi-gong-cheng-da-xue',
source: ['/', '/419/list.htm'],
target: '/nuist/xgc',
},
],
yjs: [
{
title: '研究生院学科建设处',
docs: 'https://docs.rsshub.app/university.html#nan-jing-xin-xi-gong-cheng-da-xue',
source: ['/'],
target: '/nuist/jwc/:path+',
},
],
},
};

10
lib/v2/nuist/router.js Normal file
View File

@ -0,0 +1,10 @@
module.exports = function (router) {
router.get('/bulletin/:category?', require('./bulletin'));
router.get('/cas/:category?', require('./cas'));
router.get('/jwc/:category?', require('./jwc'));
router.get('/lib', require('./library/lib'));
router.get('/scs/:category?', require('./scs'));
router.get('/sese/:category?', require('./sese'));
router.get('/xgc', require('./xgc'));
router.get(/yjs\/([\w/-]+)?/, require('./yjs'));
};

49
lib/v2/nuist/scs.js Normal file
View File

@ -0,0 +1,49 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const baseTitle = 'NUIST CS南信大计软院';
const baseUrl = 'https://scs.nuist.edu.cn';
module.exports = async (ctx) => {
const { category = 'xwkx' } = ctx.params;
const link = `${baseUrl}/${category}/list.htm`;
const response = await got(link);
const $ = cheerio.load(response.data);
const list = $('.newsList ul')
.eq(0)
.find('li')
.toArray()
.map((item) => {
item = $(item);
return {
title: item.find('a').attr('title'),
link: new URL(item.find('a').attr('href'), baseUrl).href,
pubDate: parseDate(item.find('.newsDate').text()),
};
});
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = cheerio.load(response.data);
const authorMatch = $('.newsTitleAddDate')
.text()
.match(/发布者:(.*)发布时间/);
item.author = authorMatch ? authorMatch[1].trim() : null;
item.description = $('.newsContent').html();
return item;
})
)
);
ctx.state.data = {
title: baseTitle + '' + $('head title').text(),
description: $('meta[name=description]').attr('content'),
link,
item: items,
};
};

45
lib/v2/nuist/sese.js Normal file
View File

@ -0,0 +1,45 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const baseTitle = 'NUIST ESE南信大环科院';
const baseUrl = 'https://sese.nuist.edu.cn';
module.exports = async (ctx) => {
const { category = 'tzgg1' } = ctx.params;
const link = `${baseUrl}/${category}.htm`;
const response = await got(link);
const $ = cheerio.load(response.data);
const list = $('#ctl00_ctl00_mainbody_rightbody_listcontent_NewsList .gridline')
.toArray()
.map((item) => {
item = $(item);
return {
title: item.find('a').eq(1).text(),
link: new URL(item.find('a').eq(1).attr('href'), baseUrl).href,
category: item.find('a').eq(0).text(),
pubDate: parseDate($(item).find('.gridlinedate').text(), 'YYYY年MM月DD日'),
};
});
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = cheerio.load(response.data);
item.description = $('#vsb_content_6').html();
return item;
})
)
);
ctx.state.data = {
title: baseTitle + '' + $('.lmtitle').text(),
description: $('meta[name=description]').attr('content'),
link,
item: items,
};
};

49
lib/v2/nuist/xgc.js Normal file
View File

@ -0,0 +1,49 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const baseTitle = '南信大学生工作处';
const baseUrl = 'https://xgc.nuist.edu.cn';
module.exports = async (ctx) => {
const link = baseUrl + '/419/list.htm';
const response = await got(link);
const $ = cheerio.load(response.data);
const list = $('.wp_article_list .list_item')
.toArray()
.map((item) => {
item = $(item);
return {
title: item.find('a').attr('title'),
link: new URL(item.find('a').attr('href'), baseUrl).href,
pubDate: parseDate(item.find('.Article_PublishDate').text(), 'YYYY-MM-DD'),
};
});
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
let response;
try {
response = await got(item.link);
const $ = cheerio.load(response.data);
const articleInfo = $('.arti_metas');
item.author = articleInfo.find('.arti_publisher').text().replace('作者:', '');
item.description = $('.entry').html();
} catch (e) {
// intranet
}
return item;
})
)
);
ctx.state.data = {
title: baseTitle,
link,
item: items.filter((x) => x),
};
};

60
lib/v2/nuist/yjs.js Normal file
View File

@ -0,0 +1,60 @@
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 path = ctx.path === '/yjs/' ? 'index/tzgg' : ctx.path.replace(/^\/yjs\//, '');
const rootUrl = 'https://yjs.nuist.edu.cn';
const currentUrl = `${rootUrl}/${path}.htm`;
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data);
let items = $('.gridlinediv')
.toArray()
.map((item) => {
item = $(item);
const a = item.find('a').last();
return {
title: a.text(),
link: new URL(a.attr('href'), currentUrl).href,
pubDate: parseDate(item.next().text(), 'YYYY年MM月DD日'),
};
});
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
});
const content = cheerio.load(detailResponse.data);
const timeMatches = content('.bar')
.text()
.match(/(\d{4}年\d{2}月\d{2}日 \d{2}:\d{2})/);
item.description = content('.v_news_content').html();
item.pubDate = timeMatches ? timezone(parseDate(timeMatches[1], 'YYYY年MM月DD日 HH:mm'), +8) : item.pubDate;
return item;
})
)
);
ctx.state.data = {
title: $('title').text(),
link: currentUrl,
item: items,
};
};