-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
/
yjs.ts
76 lines (67 loc) · 1.85 KB
/
yjs.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { Route } from '@/types';
import cache from '@/utils/cache';
import ofetch from '@/utils/ofetch';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
const rootURL = 'https://gsee.swjtu.edu.cn';
const urlAddr = `${rootURL}/xwzx/tzgg.htm`;
const getItem = (item) => {
const newsInfo = item.find('dt');
const newsDate = item
.find('dd')
.text()
.match(/\d{4}(-|\/|.)\d{1,2}\1\d{1,2}/)[0];
const infoTitle = newsInfo.text();
const link = rootURL + newsInfo.find('a').last().attr('href').slice(2);
return cache.tryGet(link, async () => {
const resp = await ofetch(link);
const $$ = load(resp);
const infoText = $$('.article').html();
return {
title: infoTitle,
pubDate: parseDate(newsDate),
link,
description: infoText,
};
}) as any;
};
export const route: Route = {
path: '/gsee/yjs',
categories: ['university'],
example: '/swjtu/gsee/yjs',
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: true,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['gsee.swjtu.edu.cn/'],
},
],
name: '地球科学与工程学院',
maintainers: ['E1nzbern'],
handler,
description: `研究生教育通知公告`,
};
async function handler() {
const resp = await ofetch(urlAddr);
const $ = load(resp);
const list = $('dl');
const items = await Promise.all(
list.toArray().map((i) => {
const item = $(i);
return getItem(item);
})
);
return {
title: '西南交大地学学院-研究生通知',
link: urlAddr,
item: items,
allowEmpty: true,
};
}