/
news.ts
66 lines (59 loc) · 1.83 KB
/
news.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 { getCurrentPath } from '@/utils/helpers';
const __dirname = getCurrentPath(import.meta.url);
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import path from 'node:path';
import { art } from '@/utils/render';
const rootUrl = `https://www.ssm.gov.mo`;
const newsUrl = `${rootUrl}/apps1/content/ch/973/itemlist.aspx?defaultcss=false&dlimit=20&showdate=true&dorder=cridate%20desc,displaydate%20desc&withattach=true`;
export const route: Route = {
path: '/news',
categories: ['government'],
example: '/ssm/news',
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['www.ssm.gov.mo/', 'www.ssm.gov.mo/portal'],
},
],
name: '最新消息',
maintainers: ['Fatpandac'],
handler,
url: 'www.ssm.gov.mo/',
};
async function handler() {
const response = await got.get(newsUrl);
const $ = load(response.data);
const list = $('body > div > div > ul > li');
const item = list
.map((_, item) => {
const title = $(item).find('a').text();
const link = $(item).find('a').attr('href');
const pubDate = parseDate($(item).find('small').text().split(':')[1].trim(), 'DD/MM/YYYY');
const desc = art(path.join(__dirname, 'templates/news.art'), {
link,
});
return {
title,
link,
description: desc,
pubDate,
};
})
.get();
return {
title: '澳门卫生局-最新消息',
link: rootUrl,
item,
};
}