feat(route): add support for SCNU physics school announcements and news (#12345)
* add support for SCNU physics school announcements and news * fix(route): SCNU physics school announcements and news, to pass ESLint test * fix(route): add timezone support for SCNU physics school announcements and news * fix: style * feat: add radar.js * fix: a bug * feat(route): add new route for SCNU physics school research news * fix: update doc and maintainer.js * fix: fix problems mentioned by TonyRL in PR #12345 * Update lib/v2/scnu/radar.js fix * Update lib/v2/scnu/radar.js fix * Update lib/v2/scnu/radar.js fix --------- Co-authored-by: shinonome <ziyau64@outlook.com>
This commit is contained in:
parent
6433a3cf19
commit
8c0c3d606b
|
|
@ -1560,6 +1560,18 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
|
|||
|
||||
<Route author="fengkx" example="/scnu/cs/match" path="/scnu/cs/match" radar="1"/>
|
||||
|
||||
### 物理与电信工程学院通知
|
||||
|
||||
<Route author="Shinonome28" example="/scnu/physics-school-announcements" path="/scnu/physics-school-announcements" />
|
||||
|
||||
### 物理与电信工程学院新闻
|
||||
|
||||
<Route author="Shinonome28" example="/scnu/physics-school-news" path="/scnu/physics-school-news" />
|
||||
|
||||
### 物理与电信工程学院研究动态
|
||||
|
||||
<Route author="Shinonome28" example="/scnu/physics-school-research-news" path="/scnu/physics-school-research-news" />
|
||||
|
||||
## 华中科技大学
|
||||
|
||||
### 研究生院通知公告
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@ module.exports = {
|
|||
'/cs/match': ['fengkx'],
|
||||
'/jw': ['fengkx'],
|
||||
'/library': ['fengkx'],
|
||||
'/physics-school-announcements': ['Shinonome28'],
|
||||
'/physics-school-news': ['Shinonome28'],
|
||||
'/physics-school-research-news': ['Shinonome28'],
|
||||
'/ss': ['shengmaosu'],
|
||||
'/yjs': ['shengmaosu'],
|
||||
};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,94 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const getAritlces = async (category, url, cache) => {
|
||||
const { data } = await got(url);
|
||||
const $ = cheerio.load(data);
|
||||
const spiderResult = $('ul.article-list')
|
||||
.children()
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
const a = item.find('a');
|
||||
const link = a.attr('href');
|
||||
|
||||
return {
|
||||
title: a.text(),
|
||||
link,
|
||||
pubDate: timezone(parseDate(item.find('span.time').text()), +8),
|
||||
category,
|
||||
};
|
||||
})
|
||||
.map((item) =>
|
||||
cache.tryGet(item.link, async () => {
|
||||
const { data } = await got(item.link);
|
||||
const $ = cheerio.load(data);
|
||||
const aritcleContent = $(data).find('div.detail').html();
|
||||
item.description = aritcleContent;
|
||||
return item;
|
||||
})
|
||||
);
|
||||
if (spiderResult.length === 0) {
|
||||
return [];
|
||||
}
|
||||
return Promise.all(spiderResult);
|
||||
};
|
||||
|
||||
const getItemsFromURLs = async (URLs, cache) => {
|
||||
let items = Object.keys(URLs).map((key) => getAritlces(key, URLs[key], cache));
|
||||
items = await Promise.all(items);
|
||||
items = items.flat();
|
||||
return items;
|
||||
};
|
||||
|
||||
module.exports.announcementsRouter = async (ctx) => {
|
||||
const URLs = {
|
||||
党政: 'https://physics.scnu.edu.cn/NEWS/Notices/PartyAndGovernment/',
|
||||
教务: 'https://physics.scnu.edu.cn/NEWS/Notices/Education/',
|
||||
科研: 'https://physics.scnu.edu.cn/NEWS/Notices/Research/',
|
||||
人事: 'https://physics.scnu.edu.cn/NEWS/Notices/People/',
|
||||
综合: 'https://physics.scnu.edu.cn/NEWS/Notices/General/',
|
||||
学工: 'https://physics.scnu.edu.cn/NEWS/Notices/Students/',
|
||||
};
|
||||
const items = await getItemsFromURLs(URLs, ctx.cache);
|
||||
ctx.state.data = {
|
||||
title: '华南师范大学物理与电信工程学院通知',
|
||||
link: 'https://physics.scnu.edu.cn/NEWS/Notices/',
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
||||
module.exports.newsRouter = async (ctx) => {
|
||||
const URLs = {
|
||||
学院新闻: 'https://physics.scnu.edu.cn/NEWS/News/College/',
|
||||
教务新闻: 'https://physics.scnu.edu.cn/NEWS/News/Education/',
|
||||
学工新闻: 'https://physics.scnu.edu.cn/NEWS/News/Education/',
|
||||
科研新闻: 'https://physics.scnu.edu.cn/NEWS/News/Research/',
|
||||
院友新闻: 'https://physics.scnu.edu.cn/NEWS/News/People/',
|
||||
};
|
||||
const items = await getItemsFromURLs(URLs, ctx.cache);
|
||||
ctx.state.data = {
|
||||
title: '华南师范大学物理与电信工程学院新闻动态',
|
||||
link: 'https://physics.scnu.edu.cn/NEWS/News/',
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
||||
module.exports.researchNewsRouter = async (ctx) => {
|
||||
const URLs = {
|
||||
学术报告: 'https://physics.scnu.edu.cn/RESEARCH/EVENTS/Seminars/',
|
||||
学术会议: 'https://physics.scnu.edu.cn/RESEARCH/EVENTS/Conferences/',
|
||||
科研平台: 'https://physics.scnu.edu.cn/RESEARCH/Institutes/',
|
||||
研究方向: 'https://physics.scnu.edu.cn/RESEARCH/ResearchAreas/',
|
||||
重大项目: 'https://physics.scnu.edu.cn/RESEARCH/Projects/',
|
||||
科研成果: 'https://physics.scnu.edu.cn/RESEARCH/Achievements/',
|
||||
};
|
||||
const items = await getItemsFromURLs(URLs, ctx.cache);
|
||||
ctx.state.data = {
|
||||
title: '华南师范大学物理与电信工程学院科学研究动态',
|
||||
link: 'https://physics.scnu.edu.cn/RESEARCH/',
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -25,6 +25,26 @@ module.exports = {
|
|||
target: '/scnu/library',
|
||||
},
|
||||
],
|
||||
physics: [
|
||||
{
|
||||
title: '物理与电信工程学院通知',
|
||||
docs: 'https://docs.rsshub.app/university.html#hua-nan-shi-fan-da-xue',
|
||||
source: ['/NEWS/Notices/'],
|
||||
target: '/scnu/physics-school-announcements',
|
||||
},
|
||||
{
|
||||
title: '物理与电信工程学院新闻动态',
|
||||
docs: 'https://docs.rsshub.app/university.html#hua-nan-shi-fan-da-xue',
|
||||
source: ['/NEWS/News/'],
|
||||
target: '/scnu/physics-school-news',
|
||||
},
|
||||
{
|
||||
title: '物理与电信工程学院科学研究动态',
|
||||
docs: 'https://docs.rsshub.app/university.html#hua-nan-shi-fan-da-xue',
|
||||
source: ['/RESEARCH/'],
|
||||
target: '/scnu/physics-school-research-news',
|
||||
},
|
||||
],
|
||||
ss: [
|
||||
{
|
||||
title: '软件学院通知公告',
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@ module.exports = (router) => {
|
|||
router.get('/cs/match', require('./cs/match'));
|
||||
router.get('/jw', require('./jw'));
|
||||
router.get('/library', require('./library'));
|
||||
router.get('/physics-school-announcements', require('./physics_school_announcements_and_news').announcementsRouter);
|
||||
router.get('/physics-school-news', require('./physics_school_announcements_and_news').newsRouter);
|
||||
router.get('/physics-school-research-news', require('./physics_school_announcements_and_news').researchNewsRouter);
|
||||
router.get('/ss', require('./ss'));
|
||||
router.get('/yjs', require('./yjs'));
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue