/
xygg.ts
66 lines (60 loc) 路 1.78 KB
/
xygg.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
import { Route } from '@/types';
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
export const route: Route = {
path: '/xygg',
categories: ['university'],
example: '/scvtc/xygg',
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['scvtc.edu.cn/ggfw1/xygg.htm', 'scvtc.edu.cn/'],
},
],
name: '瀛﹂櫌鍏憡',
maintainers: ['nczitzk'],
handler,
url: 'scvtc.edu.cn/ggfw1/xygg.htm',
};
async function handler() {
const currentUrl = 'https://www.scvtc.edu.cn/ggfw1/xygg.htm';
const response = await got(currentUrl);
const $ = load(response.data);
const list = $('div.text-list ul li')
.toArray()
.map((item) => {
item = $(item);
const a = item.find('a[title]');
return {
title: a.attr('title'),
link: new URL(a.attr('href'), currentUrl).href,
pubDate: parseDate(item.find('span').text().trim()),
};
});
const items = await Promise.all(
list.map((item) =>
cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
item.description = content('#vsb_content').html();
return item;
})
)
);
return {
title: $('head title').text(),
decription: $('meta[name=description]').attr('content'),
link: currentUrl,
item: items,
};
}