feat(route): add 东北师范大学研究生院 (#12641)
* feat(route): add 东北师范大学研究生院 * doc: fix typo
This commit is contained in:
parent
352cba2fdd
commit
c567ee5b94
|
|
@ -973,6 +973,22 @@ pageClass: routes
|
|||
|
||||
</Route>
|
||||
|
||||
## 东北师范大学
|
||||
|
||||
### 研究生院
|
||||
|
||||
<Route author="nczitzk" example="/nenu/yjsy" path="/nenu/yjsy/:path+" :paramsDesc="['路径,默认为通知公告']">
|
||||
|
||||
::: tip 提示
|
||||
|
||||
若订阅 [通知公告](https://yjsy.nenu.edu.cn/tzgg.htm),网址为 <https://yjsy.nenu.edu.cn/tzgg.htm>。截取 `https://yjsy.nenu.edu.cn/` 到末尾 `.htm` 的部分 `tzgg` 作为参数,此时路由为 [`/nenu/yjsy/tzgg`](https://rsshub.app/nenu/yjsy/tzgg)。
|
||||
|
||||
若订阅 [校内新闻](https://yjsy.nenu.edu.cn/xwdt/xnxw.htm),网址为 <https://yjsy.nenu.edu.cn/xwdt/xnxw.htm>。截取 `https://yjsy.nenu.edu.cn/` 到末尾 `.htm` 的部分 `xwdt/xnxw` 作为参数,此时路由为 [`/nenu/yjsy/xwdt/xnxw`](https://rsshub.app/nenu/yjsy/xwdt/xnxw)。
|
||||
|
||||
:::
|
||||
|
||||
</Route>
|
||||
|
||||
## 东莞理工学院
|
||||
|
||||
### 教务处通知
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/yjsy/:path+': ['nczitzk'],
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'nenu.edu.cn': {
|
||||
_name: '东北师范大学',
|
||||
yjsy: [
|
||||
{
|
||||
title: '研究生院',
|
||||
docs: 'https://docs.rsshub.app/university.html#dong-bei-shi-fan-da-xue-yan-jiu-sheng-yuan',
|
||||
source: ['/tzgg.htm', '/'],
|
||||
target: (params, url) => `/nenu/yjsy${new URL(url).href.match(/\.edu\.cn(.*?)\.htm/)[1]}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get(/\/yjsy([\w-/]+)?/, require('./yjsy'));
|
||||
};
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const limit = ctx.query.limit ? parseInt(ctx.query.limit) : 10;
|
||||
|
||||
const path = ctx.path === '/yjsy' ? '/tzgg' : ctx.path.replace(/^\/yjsy/, '');
|
||||
|
||||
const rootUrl = 'https://yjsy.nenu.edu.cn';
|
||||
const currentUrl = `${rootUrl}${path}.htm`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
let items = $('a.tit')
|
||||
.slice(0, limit)
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
|
||||
const link = item.attr('href');
|
||||
|
||||
return {
|
||||
title: item.text(),
|
||||
link: /^http/.test(link) ? link : new URL(link, rootUrl).href,
|
||||
};
|
||||
});
|
||||
|
||||
items = await Promise.all(
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
if (/yjsy\.nenu\.edu\.cn/.test(item.link)) {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.title = content('h2').text();
|
||||
item.description = content('.v_news_content').html();
|
||||
item.pubDate = parseDate(
|
||||
content('h3')
|
||||
.text()
|
||||
.match(/(\d{4}-\d{2}-\d{2})/)[1]
|
||||
);
|
||||
}
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue