* fix: unicorn/no-empty-file * fix: unicorn/prefer-node-protocol * fix: unicorn/prefer-number-properties * fix: unicorn/consistent-destructuring * fix: unicorn/no-array-callback-reference * fix: unicorn/new-for-builtins * fix: set checkNaN to false in unicorn/prefer-number-properties * fix: unicorn/prefer-string-slice * fix: update eslint ignore
58 lines
1.7 KiB
TypeScript
58 lines
1.7 KiB
TypeScript
import got from '@/utils/got';
|
|
import { load } from 'cheerio';
|
|
import { parseDate } from '@/utils/parse-date';
|
|
import cache from '@/utils/cache';
|
|
import { Route } from '@/types';
|
|
|
|
export const route: Route = {
|
|
path: '/jwb',
|
|
categories: ['university'],
|
|
example: '/bnu/jwb',
|
|
parameters: {},
|
|
radar: [
|
|
{
|
|
source: ['jwb.bnu.edu.cn'],
|
|
},
|
|
],
|
|
name: '教务部(研究生院)',
|
|
maintainers: ['ladeng07'],
|
|
handler,
|
|
url: 'jwb.bnu.edu.cn/tzgg/index.htm',
|
|
};
|
|
|
|
async function handler() {
|
|
const link = 'https://jwb.bnu.edu.cn/tzgg/index.htm';
|
|
const response = await got(link);
|
|
const $ = load(response.data);
|
|
const list = $('.article-list .boxlist ul li')
|
|
.toArray()
|
|
.map((e) => {
|
|
e = $(e);
|
|
const a = e.find('a');
|
|
return {
|
|
title: e.find('a span').text(),
|
|
link: a.attr('href').startsWith('http') ? a.attr('href') : 'https://jwb.bnu.edu.cn' + a.attr('href').slice(2),
|
|
pubDate: parseDate(e.find('span.fr.text-muted').text(), 'YYYY-MM-DD'),
|
|
};
|
|
});
|
|
|
|
const out = await Promise.all(
|
|
list.map((item) =>
|
|
cache.tryGet(item.link, async () => {
|
|
const response = await got(item.link);
|
|
const $ = load(response.data);
|
|
item.author = '北京师范大学教务部';
|
|
item.description = $('.contenttxt').html();
|
|
return item;
|
|
})
|
|
)
|
|
);
|
|
|
|
return {
|
|
title: '北京师范大学教务部',
|
|
link,
|
|
description: '北京师范大学教务部最新通知',
|
|
item: out,
|
|
};
|
|
}
|