feat(route): add 北京师范大学经济与工商管理学院 (#8368)
This commit is contained in:
parent
7be811e355
commit
d82186b990
|
|
@ -212,6 +212,18 @@ pageClass: routes
|
|||
|
||||
</Route>
|
||||
|
||||
## 北京师范大学
|
||||
|
||||
### 经济与工商管理学院
|
||||
|
||||
<Route author="nczitzk" example="/bnu/bs" path="/bnu/bs/:category?" :paramsDesc="['分类,见下表,默认为学院新闻']">
|
||||
|
||||
| 学院新闻 | 通知公告 | 学术成果 | 学术讲座 | 教师观点 | 人才招聘 |
|
||||
| -------- | -------- | -------- | -------- | -------- | -------- |
|
||||
| xw | zytzyyg | xzcg | xzjz | xz | bshzs |
|
||||
|
||||
</Route>
|
||||
|
||||
## 北京物资学院
|
||||
|
||||
### 通知公告
|
||||
|
|
|
|||
|
|
@ -0,0 +1,52 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category ?? 'xw';
|
||||
|
||||
const rootUrl = 'http://bs.bnu.edu.cn';
|
||||
const currentUrl = `${rootUrl}/${category}/index.html`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('a[title]')
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
|
||||
return {
|
||||
title: item.attr('title'),
|
||||
pubDate: parseDate(item.prev().text()),
|
||||
link: `${rootUrl}/${category}/${item.attr('href')}`,
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.description = content('.right-c-content-con').html();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${$('.right-c-title').text()} - ${$('title').text()}`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/bs/:category?': ['nczitzk'],
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'bnu.edu.cn': {
|
||||
_name: '北京师范大学',
|
||||
'.': [
|
||||
{
|
||||
title: '经济与工商管理学院',
|
||||
docs: 'https://docs.rsshub.app/universities.html#bei-jing-shi-fan-da-xue-jing-ji-yu-gong-shang-guan-li-xue-yuan',
|
||||
source: ['/'],
|
||||
target: '/bs/:category?',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/bs/:category?', require('./bs'));
|
||||
};
|
||||
Loading…
Reference in New Issue