feat(route): bnu fdy (#11927)

This commit is contained in:
Tony 2023-02-21 13:23:23 -04:00 committed by GitHub
parent 4ca2c8cdc4
commit c2f2a15281
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 65 additions and 0 deletions

View File

@ -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>
## 北京物资学院
### 通知公告

41
lib/v2/bnu/fdy.js Normal file
View File

@ -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,
};
};

View File

@ -1,5 +1,6 @@
module.exports = {
'/bs/:category?': ['nczitzk'],
'/dwxgb/:category/:type': ['Fatpandac'],
'/fdy/:path*': ['TonyRL'],
'/lib/:category?': ['TonyRL'],
};

View File

@ -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: '图书馆通知',

View File

@ -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'));
};