/
dafls.ts
62 lines (56 loc) · 1.72 KB
/
dafls.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
import { Route } from '@/types';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
export const route: Route = {
path: '/dafls',
categories: ['university'],
example: '/nju/dafls',
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['dafls.nju.edu.cn/13167/list.html', 'dafls.nju.edu.cn/'],
},
],
name: '大学外语部',
maintainers: ['ret-1'],
handler,
url: 'dafls.nju.edu.cn/13167/list.html',
};
async function handler() {
const category_dict = {
tzgg: '通知公告',
};
const items = await Promise.all(
Object.keys(category_dict).map(async (c) => {
const response = await got(`https://dafls.nju.edu.cn/13167/list.htm`);
const data = response.data;
const $ = load(data);
const list = $('#article97');
// only read first page
return list.map((index, item) => {
item = $(item);
return {
title: item.find('a').last().text(),
link: 'https://dafls.nju.edu.cn' + item.find('a').attr('href'),
pubDate: timezone(parseDate(item.find('span').last().text(), 'YYYY-MM-DD'), +8),
category: c,
};
});
})
);
return {
title: '大外部-通知公告',
link: 'https://dafls.nju.edu.cn/13167/list.htm',
item: [...items[0]],
};
}