Files
RSSHub/lib/v2/jsu/jwc.js
T
01a56d98c2 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>
2024-02-22 22:22:33 +08:00

60 lines
2.2 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 导入必要的模组
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,
};
};