feat(route): bnu lib (#11925)

This commit is contained in:
Tony
2023-02-21 22:57:18 +08:00
committed by GitHub
parent 450dd72927
commit dd0c1a32f2
5 changed files with 73 additions and 10 deletions
+15 -5
View File
@@ -278,6 +278,16 @@ pageClass: routes
<Route author="markmingjie" example="/bjfu/kjc" path="/bjfu/kjc" />
### 信息学院通知
<Route author="wzc-blog" example="/bjfu/it/xyxw" path="/bjfu/it/:type" :paramsDesc="['通知类别']">
| 学院新闻 | 科研动态 | 本科生培养 | 研究生培养 |
| ---- | ---- | ----- | ----- |
| xyxw | kydt | pydt | pydt2 |
</Route>
### 教务处通知公告
<Route author="markmingjie" example="/bjfu/jwc/jwkx" path="/bjfu/jwc/:type" :paramsDesc="['通知类别']">
@@ -310,13 +320,13 @@ pageClass: routes
</Route>
### 信息学院通知
### 图书馆通知
<Route author="wzc-blog" example="/bjfu/it/xyxw" path="/bjfu/it/:type" :paramsDesc="['通知类别']">
<Route author="TonyRL" example="/bnu/lib/zydt" path="/bjfu/lib/:category?" :paramsDesc="['分类,见下表,默认为 `zydt`']" radar="1">
| 学院新闻 | 科研动态 | 本科生培养 | 研究生培养 |
| ---- | ---- | ----- | ----- |
| xyxw | kydt | pydt | pydt2 |
| 资源动态 | 新闻动态 | 系列讲座 |
| ---- | ---- | ----- |
| zydt | xwdt | xljz1 |
</Route>
+40
View File
@@ -0,0 +1,40 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const baseUrl = 'http://www.lib.bnu.edu.cn';
const { category = 'zydt' } = ctx.params;
const link = `${baseUrl}/${category}/index.htm`;
const { data: response } = await got(link);
const $ = cheerio.load(response);
const list = $('.view-content .item-list li')
.toArray()
.map((item) => {
item = $(item);
return {
title: item.find('a').text(),
link: `${baseUrl}/${category}/${item.find('a').attr('href')}`,
pubDate: parseDate(item.find('span > span').eq(1).text(), 'YYYY-MM-DD'),
};
});
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = cheerio.load(response);
item.description = $('#block-system-main .content .content').html();
return item;
})
)
);
ctx.state.data = {
title: $('head title').text(),
link,
item: items,
};
};
+2
View File
@@ -1,3 +1,5 @@
module.exports = {
'/bs/:category?': ['nczitzk'],
'/dwxgb/:category/:type': ['Fatpandac'],
'/lib/:category?': ['TonyRL'],
};
+15 -5
View File
@@ -1,19 +1,29 @@
module.exports = {
'bnu.edu.cn': {
_name: '北京师范大学',
'.': [
bs: [
{
title: '经济与工商管理学院',
docs: 'https://docs.rsshub.app/university.html#bei-jing-shi-fan-da-xue',
source: ['/'],
target: '/bs/:category?',
source: ['/:category/index.html'],
target: '/bnu/bs/:category',
},
],
dwxgb: [
{
title: '经济与工商管理学院',
title: '党委学生工作部',
docs: 'https://docs.rsshub.app/university.html#bei-jing-shi-fan-da-xue',
source: ['/'],
source: ['/:category/:type/index.html'],
target: '/bnu/dwxgb/:category/:type',
},
],
'www.lib': [
{
title: '图书馆通知',
docs: 'https://docs.rsshub.app/university.html#bei-jing-shi-fan-da-xue',
source: ['/:category/index.htm'],
target: '/bnu/lib/:category',
},
],
},
};
+1
View File
@@ -1,4 +1,5 @@
module.exports = function (router) {
router.get('/bs/:category?', require('./bs'));
router.get('/dwxgb/:category/:type', require('./dwxgb'));
router.get('/lib/:category?', require('./lib'));
};