/
exchangesys.ts
68 lines (64 loc) · 2.16 KB
/
exchangesys.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
import { Route } from '@/types';
import got from '@/utils/got';
import dayjs from 'dayjs';
export const route: Route = {
path: '/exchangesys/:type',
categories: ['university'],
example: '/nju/exchangesys/proj',
parameters: { type: '分类名' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
name: '本科生交换生系统',
maintainers: [],
handler,
description: `| 新闻通知 | 交换生项目 |
| -------- | ---------- |
| news | proj |`,
};
async function handler(ctx) {
const type = ctx.req.param('type');
const type_dict = {
news: ['http://elite.nju.edu.cn/exchangesystem/index/moreList', 'http://elite.nju.edu.cn/exchangesystem/index/more?type=xw', '新闻通知'],
proj: ['http://elite.nju.edu.cn/exchangesystem/index/moreXmList', 'http://elite.nju.edu.cn/exchangesystem/index/more?type=xm', '交换生项目'],
};
const url = type_dict[type][0] + '?page=1&limit=20&.me=c3lzLmluZGV4';
const { data } = await got({
url,
headers: {
Referer: type_dict[type][1],
},
});
return {
title: `本科生交换生管理系统-${type_dict[type][2]}`,
link: type_dict[type][1],
item:
data &&
data.data &&
data.data.map((item) => {
if (type === 'proj') {
return {
title: item.mc,
description: item.mc,
pubDate: dayjs(item.cjsj),
link: item.sqyq,
};
}
if (type === 'news') {
return {
title: item.bt,
author: item.createBy,
description: item.nr,
pubDate: dayjs(item.createDate),
link: `http://elite.nju.edu.cn/exchangesystem/index/detail?pid=${item.pid}`,
};
}
return null;
}),
};
}