feat(route): bnu fdy (#11927)
This commit is contained in:
parent
4ca2c8cdc4
commit
c2f2a15281
|
|
@ -330,6 +330,20 @@ pageClass: routes
|
|||
|
||||
</Route>
|
||||
|
||||
### 党委学生工作部辅导员发展中心
|
||||
|
||||
<Route author="TonyRL" example="/bnu/fdy/tzgg/dwjs" path="/bnu/fdy/:path*" :paramsDesc="['路径,默认为 `tzgg`']" radar="1">
|
||||
|
||||
::: tip 提示
|
||||
|
||||
路径处填写对应页面 URL 中 `https://fdy.bnu.edu.cn/` 和 `/index.htm` 之间的字段。下面是一个例子。
|
||||
|
||||
若订阅 [通知公告 > 队伍建设](https://fdy.bnu.edu.cn/tzgg/dwjs/index.htm) 则将对应页面 URL <https://fdy.bnu.edu.cn/tzgg/dwjs/index.htm> 中 `https://fdy.bnu.edu.cn/` 和 `/index.htm` 之间的字段 `tzgg/dwjs` 作为路径填入。此时路由为 [`/bnu/fdy/tzgg/dwjs`](https://rsshub.app/bnu/fdy/tzgg/dwjs)
|
||||
|
||||
:::
|
||||
|
||||
</Route>
|
||||
|
||||
## 北京物资学院
|
||||
|
||||
### 通知公告
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const baseUrl = 'http://fdy.bnu.edu.cn';
|
||||
const { path = 'tzgg' } = ctx.params;
|
||||
const link = `${baseUrl}/${path}/index.htm`;
|
||||
|
||||
const { data: response } = await got(link);
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
const list = $('.listconrl li')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
const a = item.find('a');
|
||||
return {
|
||||
title: a.attr('title'),
|
||||
link: new URL(a.attr('href'), link).href,
|
||||
pubDate: parseDate(item.find('.news-dates').text()),
|
||||
};
|
||||
});
|
||||
|
||||
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 = $('.listconrc-newszw').html();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('head title').text(),
|
||||
link,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
module.exports = {
|
||||
'/bs/:category?': ['nczitzk'],
|
||||
'/dwxgb/:category/:type': ['Fatpandac'],
|
||||
'/fdy/:path*': ['TonyRL'],
|
||||
'/lib/:category?': ['TonyRL'],
|
||||
};
|
||||
|
|
|
|||
|
|
@ -17,6 +17,14 @@ module.exports = {
|
|||
target: '/bnu/dwxgb/:category/:type',
|
||||
},
|
||||
],
|
||||
fdy: [
|
||||
{
|
||||
title: '党委学生工作部辅导员发展中心',
|
||||
docs: 'https://docs.rsshub.app/university.html#bei-jing-shi-fan-da-xue',
|
||||
source: ['/'],
|
||||
target: (_, url) => `/bnu/fdy${new URL(url).pathname.replace(/\/index\.htm(l)?$/, '')}`,
|
||||
},
|
||||
],
|
||||
'www.lib': [
|
||||
{
|
||||
title: '图书馆通知',
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/bs/:category?', require('./bs'));
|
||||
router.get('/dwxgb/:category/:type', require('./dwxgb'));
|
||||
router.get('/fdy/:path*', require('./fdy'));
|
||||
router.get('/lib/:category?', require('./lib'));
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue