mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-01 17:48:15 +08:00
feat(route): add 华理教务处 (#12982)
* add ECUST-jwc rss route * fix code * fix review
This commit is contained in:
@@ -1587,6 +1587,16 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
|
|||||||
|
|
||||||
<Route author="jialinghui" example="/ecust/jxjy/news" path="/ecust/jxjy/news" radar="1" rssbud="1" />
|
<Route author="jialinghui" example="/ecust/jxjy/news" path="/ecust/jxjy/news" radar="1" rssbud="1" />
|
||||||
|
|
||||||
|
### 本科教务处信息网
|
||||||
|
|
||||||
|
<Route author="lxl66566" example="/ecust/jwc/mto" path="/ecust/jwc/:category?" :paramsDesc="['订阅板块,默认为全部订阅']">
|
||||||
|
|
||||||
|
| 其他任意值 | mto | mttb | gi | mpt | fai |
|
||||||
|
| --- | --- | --- | --- | --- | --- |
|
||||||
|
| 全部订阅 | 教学运行管理 | 培养与教学建设管理 | 综合信息 | 实践教学管理 | 学院教务信息 |
|
||||||
|
|
||||||
|
</Route>
|
||||||
|
|
||||||
## 华东师范大学
|
## 华东师范大学
|
||||||
|
|
||||||
### ACM OJ 比赛列表
|
### ACM OJ 比赛列表
|
||||||
|
|||||||
66
lib/v2/ecust/jwc/notice.js
Normal file
66
lib/v2/ecust/jwc/notice.js
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const { parseDate } = require('@/utils/parse-date');
|
||||||
|
|
||||||
|
const baseUrl = 'https://jwc.ecust.edu.cn';
|
||||||
|
const categoryMap = {
|
||||||
|
mto: { link: '/3938', name: '教学运行管理' },
|
||||||
|
mttb: { link: '/3939', name: '培养与教学建设管理' },
|
||||||
|
gi: { link: '/zhglbgs', name: '综合信息' },
|
||||||
|
mpt: { link: '/3940', name: '实践教学管理' },
|
||||||
|
fai: { link: '/3941', name: '学院教务信息' },
|
||||||
|
};
|
||||||
|
const get_from_link = async (link) => {
|
||||||
|
const { data: response } = await got(link);
|
||||||
|
const $ = cheerio.load(response);
|
||||||
|
const articleList = $('div#wp_news_w2 table[width="100%"]')
|
||||||
|
.toArray()
|
||||||
|
.map((item) => {
|
||||||
|
const a = $(item).find('a');
|
||||||
|
const date = $(item).find('div[style="white-space:nowrap"]').first();
|
||||||
|
// deal with article_link
|
||||||
|
let articleLink = a.attr('href');
|
||||||
|
if (!articleLink.startsWith('http')) {
|
||||||
|
articleLink = `${baseUrl}${articleLink}`;
|
||||||
|
}
|
||||||
|
articleLink = articleLink.replace(/^https:\/\/(\w+)-ecust-edu-cn-s\.sslvpn\.ecust\.edu\.cn:8118/, 'https://$1.ecust.edu.cn').replace(/^https:\/\/ecust-edu-cn-s\.sslvpn\.ecust\.edu\.cn:8118/, 'https://ecust.edu.cn');
|
||||||
|
return {
|
||||||
|
title: a.text(),
|
||||||
|
link: articleLink,
|
||||||
|
pubDate: parseDate(date.text()),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
return articleList;
|
||||||
|
};
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const { category = 'all' } = ctx.params;
|
||||||
|
const categoryItem = categoryMap[category] || null; // all -> null
|
||||||
|
const pageUrl = categoryItem ? [`${baseUrl}${categoryItem.link}/list.htm`] : Object.values(categoryMap).map((item) => `${baseUrl}${item.link}/list.htm`);
|
||||||
|
const items = (await Promise.all(pageUrl.map((link) => get_from_link(link)))).flat();
|
||||||
|
const result = await Promise.all(
|
||||||
|
items.map((item) =>
|
||||||
|
ctx.cache.tryGet(item.link, async () => {
|
||||||
|
const { data: response } = await got(item.link);
|
||||||
|
const content = cheerio.load(response);
|
||||||
|
// remove all attrs and empty objects
|
||||||
|
content('div.wp_articlecontent *').each(function () {
|
||||||
|
if (!content(this).text().trim()) {
|
||||||
|
return content(this).remove();
|
||||||
|
}
|
||||||
|
for (const attr in this.attribs) {
|
||||||
|
content(this).removeAttr(attr);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const description = content('div.wp_articlecontent').first().html();
|
||||||
|
// merge same objects, replace two times instead of replace recursively
|
||||||
|
description && (item.description = description.replace(/<\/(p|span|strong)>\s*<\1>/g, '').replace(/<\/(p|span|strong)>\s*<\1>/g, ''));
|
||||||
|
return item;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
ctx.state.data = {
|
||||||
|
title: `华理教务处 - ${categoryItem ? categoryItem.name : '全部'}`,
|
||||||
|
link: categoryItem ? pageUrl[0] : baseUrl,
|
||||||
|
item: result,
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
|
'/jwc/:category?': ['lxl66566'],
|
||||||
'/jxjy/news': ['jialinghui'],
|
'/jxjy/news': ['jialinghui'],
|
||||||
'/yjs': ['shengmaosu'],
|
'/yjs': ['shengmaosu'],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,5 +17,13 @@ module.exports = {
|
|||||||
target: '/ecust/yjs',
|
target: '/ecust/yjs',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
jwc: [
|
||||||
|
{
|
||||||
|
title: '本科教务处信息网',
|
||||||
|
docs: 'https://docs.rsshub.app/university.html#hua-dong-li-gong-da-xue',
|
||||||
|
source: ['/'],
|
||||||
|
target: '/ecust/jwc/notice/:category?',
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
module.exports = function (router) {
|
module.exports = function (router) {
|
||||||
|
router.get('/jwc/:category?', require('./jwc/notice'));
|
||||||
router.get('/jxjy/news', require('./e/news'));
|
router.get('/jxjy/news', require('./e/news'));
|
||||||
router.get('/yjs', require('./gschool/yjs'));
|
router.get('/yjs', require('./gschool/yjs'));
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user