/
kyjz.ts
73 lines (64 loc) · 2.08 KB
/
kyjz.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
import { Route } from '@/types';
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
const host = 'http://www.sim.cas.cn/';
export const route: Route = {
path: '/sim/kyjz',
categories: ['university'],
example: '/cas/sim/kyjz',
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['www.sim.cas.cn/xwzx2016/kyjz', 'www.sim.cas.cn/'],
},
],
name: '上海微系统与信息技术研究所 科技进展',
maintainers: ['HenryQW'],
handler,
url: 'www.sim.cas.cn/xwzx2016/kyjz',
};
async function handler() {
const link = new URL('xwzx2016/kyjz/', host).href;
const response = await got(link);
const $ = load(response.data);
const list = $('.list-news li')
.toArray()
.filter((e) => !$(e).attr('style'))
.map((e) => {
e = $(e);
return {
link: new URL(e.find('a').attr('href'), link).href,
pubDate: e.find('span').text().replace('[', '').replace(']', ''),
};
});
const out = await Promise.all(
list.map((item) =>
cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
const author = $('.qtinfo.hidden-lg.hidden-md.hidden-sm').text();
const reg = /文章来源:(.*?)\|/g;
item.title = $('p.wztitle').text().trim();
item.author = reg.exec(author)[1].toString().trim();
item.description = $('.TRS_Editor').html();
item.pubDate = parseDate(item.pubDate);
return item;
})
)
);
return {
title: '中国科学院上海微系统与信息技术研究所 -- 科技进展',
link,
item: out,
};
}