feat(route): add 吉首大学相关通知公告 (#14514)

* feat(route): add 吉首大学相关通知公告

* feat(route): add 吉首大学计算机科学与工程学院、吉首大学数统学院、吉首大学主站、创新中心通知公告、教务处教务动态、教务通知

* fix: 修复文档问题

* feat(route): add 吉首大学相关通知公告

* fea(route): add 吉首大学计算机科学与工程学院、吉首大学数统学院、吉首大学主站、创新中心通知公告、教务处教务动态、教务通知

* feat(route): add 吉首大学相关通知公告

* feat(route): add 吉首大学计算机科学与工程学院、吉首大学数统学院、吉首大学主站、创新中心通知公告、教务处教务动态、教务通知

* feat(route): add 吉首大学相关通知公告

* fea(route): add 吉首大学计算机科学与工程学院、吉首大学数统学院、吉首大学主站、创新中心通知公告、教务处教务动态、教务通知

* feat(route): add 吉首大学相关通知公告

* fea(route): add 吉首大学计算机科学与工程学院、吉首大学数统学院、吉首大学主站、创新中心通知公告、教务处教务动态、教务通知

* Update lib/v2/jsu/cxzx.js

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

* Update lib/v2/jsu/radar.js

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

* Update lib/v2/jsu/utils/index.js

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

* Update lib/v2/jsu/radar.js

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

* Update lib/v2/jsu/radar.js

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

* Update lib/v2/jsu/radar.js

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

* Update lib/v2/jsu/radar.js

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

* feat(route): add 吉首大学相关通知公告

* fea(route): add 吉首大学计算机科学与工程学院、吉首大学数统学院、吉首大学主站、创新中心通知公告、教务处教务动态、教务通知

* fix: 修复教务处返回的标题和描述为”计算机学院“

* style: 参照其他PR中Maintainer给出的建议,对radar.js 和 maintainer.js以字典序排序。

* refactor: 将整个RSS项对象作为缓存而不是单仅正文作为缓存,同时对应的修改了正文获取工具类中的内容,去除了固定的UserAgent;

* feat(route): add 吉首大学相关通知公告

* fea(route): add 吉首大学计算机科学与工程学院、吉首大学数统学院、吉首大学主站、创新中心通知公告、教务处教务动态、教务通知

* fix: 修复教务处返回的标题和描述为”计算机学院“

* style: 参照其他PR中Maintainer给出的建议,对radar.js 和 maintainer.js以字典序排序。

* refactor: 将整个RSS项对象作为缓存而不是单仅正文作为缓存,同时对应的修改了正文获取工具类中的内容,去除了固定的UserAgent;

* Update website/docs/routes/university.mdx

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

* Update website/docs/routes/university.mdx

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

* Update lib/v2/jsu/math.js

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

* Update lib/v2/jsu/universityindex.js

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

* feat(route): add 吉首大学相关通知公告

* fea(route): add 吉首大学计算机科学与工程学院、吉首大学数统学院、吉首大学主站、创新中心通知公告、教务处教务动态、教务通知

* fix: 修复教务处返回的标题和描述为”计算机学院“

* style: 参照其他PR中Maintainer给出的建议,对radar.js 和 maintainer.js以字典序排序。

* refactor: 将整个RSS项对象作为缓存而不是单仅正文作为缓存,同时对应的修改了正文获取工具类中的内容,去除了固定的UserAgent;

* Update lib/v2/jsu/rjxy.js

* Update lib/v2/jsu/math.js

* Update lib/v2/jsu/jwc.js

---------

Co-authored-by: WenjiaChen <i@wenjiachen.cn>
This commit is contained in:
Ben Chen 2024-02-22 22:22:33 +08:00 committed by GitHub
parent cdc36d3554
commit 01a56d98c2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 399 additions and 0 deletions

75
lib/v2/jsu/cxzx.js Normal file
View File

@ -0,0 +1,75 @@
// 导入必要的模组
const got = require('@/utils/got'); // 自订的 got
const cheerio = require('cheerio'); // 可以使用类似 jQuery 的 API HTML 解析器
const { parseDate } = require('@/utils/parse-date');
const { getPageItemAndDate } = require('./utils/index');
module.exports = async (ctx) => {
// 在此处编写您的逻辑
const { types = 'xkjs' } = ctx.params;
const baseUrl = 'https://cxzx.jsu.edu.cn/';
const urls = {
tzgg: {
url: 'https://cxzx.jsu.edu.cn/xwzx.htm',
title: '通知公告',
}, // 通知公告页面
xkjs: {
url: 'https://cxzx.jsu.edu.cn/xwzx/zxdt.htm',
title: '学科竞赛公告',
},
cxtz: {
url: 'https://cxzx.jsu.edu.cn/cxlt/xsjz1.htm',
title: '创新项目公告',
},
jsxw: {
url: 'https://cxzx.jsu.edu.cn/cxjs.htm',
title: '竞赛新闻',
},
jstz: {
url: 'https://cxzx.jsu.edu.cn/cxjs/xkjs.htm',
title: '竞赛新闻 -> 通知公告',
},
};
// 获取页面中所有的 body > div.cx_big_container > div.cx_content_container > div.cx_right_part > div.cx_article_list_box > table > tbody > tr
const response = await got({
method: 'get',
url: urls[types].url,
});
const $ = cheerio.load(response.data);
const list = $('tr[height="20"]').toArray();
const out = await Promise.all(
list.map((item) => {
item = $(item);
const link = new URL(item.find('td:nth-child(2) > a').attr('href'), baseUrl).href;
return ctx.cache.tryGet(link, async () => {
const title = item.find('td:nth-child(2) > a').text() || '无标题';
const category = urls[types].title;
const description = await getPageItemAndDate(
'#vsb_newscontent',
link,
'body > div.cx_big_container > div.cx_content_container > div.cx_right_part > div.viewbox > form > table > tbody > tr:nth-child(1) > td',
'body > div.cx_big_container > div.cx_content_container > div.cx_right_part > div.viewbox > form > table > tbody > tr:nth-child(2) > td > span.timestyle134612'
);
const pubDate = parseDate(description.date);
return {
title,
link,
pubDate,
description: description.pageInfo,
category,
};
});
})
);
ctx.state.data = {
// 在此处输出您的 RSS
title: `吉首大学创新中心 - ${urls[types].title}`,
link: urls[types].url,
description: '吉首大学创新中心',
item: out,
};
};

59
lib/v2/jsu/jwc.js Normal file
View File

@ -0,0 +1,59 @@
// 导入必要的模组
const got = require('@/utils/got'); // 自订的 got
const cheerio = require('cheerio'); // 可以使用类似 jQuery 的 API HTML 解析器
const { parseDate } = require('@/utils/parse-date');
const { getPageItemAndDate } = require('@/v2/jsu/utils');
module.exports = async (ctx) => {
const baseUrl = 'https://jwc.jsu.edu.cn/';
const { types = 'jwtz' } = ctx.params;
const selectors = {
jwtz: {
category: '教务通知',
url: 'https://jwc.jsu.edu.cn/tzgg.htm',
},
jwdt: {
category: '教务动态',
url: 'https://jwc.jsu.edu.cn/jwdt.htm',
},
};
const response = await got({
method: 'get',
url: selectors[types].url,
});
const $ = cheerio.load(response.data);
const list = $('a.c135042').toArray();
const out = await Promise.all(
list.map((item) => {
item = $(item);
const link = new URL(item.attr('href'), baseUrl).href;
return ctx.cache.tryGet(link, async () => {
const description = await getPageItemAndDate(
'#vsb_content',
link,
'body > div.w1180.nyWrap.clearfix > div.nyRight > div > div.passage.contPsg > form > div > h1',
'body > div.w1180.nyWrap.clearfix > div.nyRight > div > div.passage.contPsg > form > div > div:nth-child(2)',
(date) => date.split('     文章来源:')[0].split('添加时间:')[1]
);
const category = selectors[types].category;
const pubDate = parseDate(description.date, 'YYYY年MM月DD日');
return {
title: description.title,
link,
pubDate,
description: description.pageInfo,
category,
};
});
})
);
ctx.state.data = {
// 在此处输出您的 RSS
title: `吉首大学教务处 - ${selectors[types].category}`,
link: selectors[types].url,
description: `吉首大学教务处 - ${selectors[types].category}`,
item: out,
};
};

7
lib/v2/jsu/maintainer.js Normal file
View File

@ -0,0 +1,7 @@
module.exports = {
'/cxzx/:types?': ['wenjia03'],
'/jwc/:types?': ['wenjia03'],
'/notice': ['wenjia03'],
'/rjxy': ['wenjia03'],
'/stxy': ['wenjia03'],
};

41
lib/v2/jsu/math.js Normal file
View File

@ -0,0 +1,41 @@
// 导入必要的模组
const got = require('@/utils/got'); // 自订的 got
const cheerio = require('cheerio'); // 可以使用类似 jQuery 的 API HTML 解析器
const { parseDate } = require('@/utils/parse-date');
const { getPageItemAndDate } = require('@/v2/jsu/utils');
module.exports = async (ctx) => {
const baseUrl = 'https://stxy.jsu.edu.cn/';
const response = await got({
method: 'get',
url: 'https://stxy.jsu.edu.cn/index/tzgg1.htm',
});
const $ = cheerio.load(response.data);
const list = $('div.art_list').toArray();
const out = await Promise.all(
list.map((item) => {
item = $(item);
const link = new URL(item.find('a').attr('href'), baseUrl).href;
return ctx.cache.tryGet(link, async () => {
const description = await getPageItemAndDate('#right_con > form > div.articleInfo', link, '#right_con > form > div.articleTitle', '#right_con > form > div.articleAuthor > span:nth-child(1)');
const pubDate = parseDate(description.date, 'YYYY年MM月DD日 HH:mm');
return {
title: description.title,
link,
pubDate,
description: description.pageInfo,
category: '通知公告',
};
});
})
);
ctx.state.data = {
title: '吉首大学数学与统计学院 - 通知公告',
link: 'https://stxy.jsu.edu.cn/index/tzgg1.htm',
description: '吉首大学数学与统计学院 - 通知公告',
item: out,
};
};

36
lib/v2/jsu/radar.js Normal file
View File

@ -0,0 +1,36 @@
module.exports = {
'jsu.edu.cn': {
_name: '吉首大学',
'.': [
{
title: '通知公告',
docs: 'https://docs.rsshub.app/routes/university#ji-shou-da-xue-tong-zhi-gong-gao',
},
],
'cxzx': [
{
title: '创新中心',
docs: 'https://docs.rsshub.app/routes/university#ji-shou-da-xue-chuang-xin-zhong-xin',
},
],
'jwc': [
{
title: '教务处',
docs: 'https://docs.rsshub.app/routes/university#ji-shou-da-xue-jiao-wu-chu',
},
],
'rjxy': [
{
title: '计算机科学与工程学院',
docs: 'https://docs.rsshub.app/routes/university##ji-shou-da-xue-ji-suan-ji-ke-xue-yu-gong-cheng-xue-yuan',
},
],
'stxy': [
{
title: '数学与统计学院',
docs: 'https://docs.rsshub.app/routes/university#ji-shou-da-xue-shu-xue-yu-tong-ji-xue-yuan',
},
],
},
};

43
lib/v2/jsu/rjxy.js Normal file
View File

@ -0,0 +1,43 @@
// 导入必要的模组
const got = require('@/utils/got'); // 自订的 got
const cheerio = require('cheerio'); // 可以使用类似 jQuery 的 API HTML 解析器
const { parseDate } = require('@/utils/parse-date');
const { getPageItemAndDate } = require('@/v2/jsu/utils');
module.exports = async (ctx) => {
const baseUrl = 'https://rjxy.jsu.edu.cn/';
const response = await got({
method: 'get',
url: 'https://rjxy.jsu.edu.cn/index/tzgg1.htm',
});
const $ = cheerio.load(response.data);
const list = $('body > div.list-box > div > ul > li').toArray();
const out = await Promise.all(
list.map((item) => {
item = $(item);
const link = new URL(item.find('a').attr('href'), baseUrl).href;
return ctx.cache.tryGet(link, async () => {
const category = '通知公告';
const description = await getPageItemAndDate('#vsb_content', link, 'body > form > div > h1', 'body > form > div > div.label', (date) => date.split(' 点击:')[0]);
const pubDate = parseDate(description.date, 'YYYY年MM月DD日 HH:mm');
return {
title: description.title,
link,
pubDate,
description: description.pageInfo,
category,
};
});
})
);
ctx.state.data = {
// 在此处输出您的 RSS
title: '吉首大学计算机科学与工程学院 - 通知公告',
link: 'https://rjxy.jsu.edu.cn/index/tzgg1.htm',
description: '吉首大学计算机科学与工程学院 - 通知公告',
item: out,
};
};

8
lib/v2/jsu/router.js Normal file
View File

@ -0,0 +1,8 @@
module.exports = (router) => {
// 创新中心
router.get('/cxzx/:types?', require('./cxzx'));
router.get('/jwc/:types?', require('./jwc'));
router.get('/notice', require('./universityindex'));
router.get('/rjxy', require('./rjxy'));
router.get('/stxy', require('./math'));
};

View File

@ -0,0 +1,48 @@
// 导入必要的模组
const got = require('@/utils/got'); // 自订的 got
const cheerio = require('cheerio'); // 可以使用类似 jQuery 的 API HTML 解析器
const { parseDate } = require('@/utils/parse-date');
const { getPageItemAndDate } = require('./utils');
module.exports = async (ctx) => {
const baseUrl = 'https://www.jsu.edu.cn/';
const response = await got({
method: 'get',
url: 'https://www.jsu.edu.cn/index/tzgg.htm',
});
const $ = cheerio.load(response.data);
const list = $('body > div.container.container-fluid.dynava.no-padding.cleafix > div.con_wz_fr.fr.cleafix > div:nth-child(2) > ul > li').toArray();
const out = await Promise.all(
list.map((item) => {
item = $(item);
const link = new URL(item.find('a').attr('href'), baseUrl).href;
return ctx.cache.tryGet(link, async () => {
const description = await getPageItemAndDate(
'#vsb_content',
link,
'body > div.container.container-fluid.dynava.no-padding.cleafix > div.con_wz_fr.fr.cleafix > form > div > h1',
'body > div.container.container-fluid.dynava.no-padding.cleafix > div.con_wz_fr.fr.cleafix > form > div > div:nth-child(2)',
(date) => date.split('时间:')[1].split(' 作者:')[0]
);
const pubDate = parseDate(description.date, 'YYYY-MM-DD');
return {
title: description.title,
link,
pubDate,
description: description.pageInfo,
category: '通知公告',
};
});
})
);
ctx.state.data = {
// 在此处输出您的 RSS
title: '吉首大学 - 通知公告',
link: 'https://www.jsu.edu.cn/index/tzgg.htm',
description: '吉首大学 - 通知公告',
item: out,
};
};

52
lib/v2/jsu/utils/index.js Normal file
View File

@ -0,0 +1,52 @@
const got = require('@/utils/got'); // 自订的 got
const cheerio = require('cheerio'); // 可以使用类似 jQuery 的 API HTML 解析器
/**
* 获取页面内容
* @param selector 正文CSS选择器
* @param pageUrl 页面URL
* @returns {Promise<string|string>} 页面内容为符合RSS规范的HTML
*/
async function getPageItem(selector, pageUrl) {
const response = await got({
method: 'get',
url: pageUrl,
https: { rejectUnauthorized: false },
});
const $ = cheerio.load(response.data);
const page = $(selector);
return page ? page.html() : '无法获取内容';
}
/**
* 获取页面内容标题日期
* @param selector 正文CSS选择器
* @param pageUrl 页面URL
* @param titleSelector 标题CSS选择器
* @param dateSelector 日期CSS选择器
* @param dateHander 日期处理函数在CMS系统中会以日期点击数等特殊格式显示日期需要处理切分出日期
* @returns {Promise<{date, pageInfo: string, title: (*|jQuery|string)}|{date: string, pageInfo: string, title: string}>} 页面内容标题日期
*/
async function getPageDetails(selector, pageUrl, titleSelector, dateSelector, dateHander = (date) => date) {
const response = await got({
method: 'get',
url: pageUrl,
https: { rejectUnauthorized: false },
});
const $ = cheerio.load(response.data);
const page = $(selector);
const date = dateHander($(dateSelector).text());
const title = $(titleSelector).text();
return page
? { pageInfo: page.html(), date, title }
: {
pageInfo: '无法获取内容',
date: '1970-1-1',
title: '无法获取标题',
};
}
module.exports = {
getPageItem,
getPageItemAndDate: getPageDetails,
};

View File

@ -3655,3 +3655,33 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE\_TL
| -------- | -------- | -------- | -------- |
| results | papers | writings | policy |
</Route>
## 吉首大学 {#ji-shou-da-xue}
### 通知公告 {#ji-shou-da-xue-tong-zhi-gong-gao}
<Route author="wenjia03" example="/jsu/notice" path="/jsu/notice"/>
### 计算机科学与工程学院 - 通知公告 {#ji-shou-da-xue-ji-suan-ji-ke-xue-yu-gong-cheng-xue-yuan}
<Route author="wenjia03" example="/jsu/rjxy" path="/jsu/rjxy"/>
### 教务处 {#ji-shou-da-xue-jiao-wu-chu}
<Route author="wenjia03" example="/jsu/jwc/jwdt" path="/jsu/jwc/:types?" paramsDesc={['通知分类 默认为`jwtz`']}>
| 教务通知 | 教务动态 |
| ---- | ---- |
| jwtz | jwdt |
</Route>
### 数学与统计学院 - 通知公告{#ji-shou-da-xue-shu-xue-yu-tong-ji-xue-yuan}
<Route author="wenjia03" example="/jsu/stxy" path="/jsu/stxy"/>
### 创新中心 {#ji-shou-da-xue-chuang-xin-zhong-xin}
<Route author="wenjia03" example="/cxzx/xkjs" path="/cxzx/:types?" paramsDesc={['通知分类 默认为`xkjs`']}>
| 通知公告 | 学科竞赛公告 | 创新项目公告 | 竞赛新闻 | 竞赛通知 |
| ------ | ----------- | ---------- | ------ | ------- |
| tzgg | xkjs | cxtz | jsxw | jstz |
</Route>