/
index.ts
65 lines (62 loc) 路 1.81 KB
/
index.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
import { Route } from '@/types';
import { rootUrl, asyncPoolAll, parseNewsList, parseArticle } from './utils';
const site_title_mapping = {
'/': 'News',
bpol: 'Politics',
bbiz: 'Business',
markets: 'Markets',
technology: 'Technology',
green: 'Green',
wealth: 'Wealth',
pursuits: 'Pursuits',
bview: 'Opinion',
equality: 'Equality',
businessweek: 'Businessweek',
citylab: 'CityLab',
};
export const route: Route = {
path: '/:site?',
categories: ['finance'],
example: '/bloomberg/bbiz',
parameters: {
site: 'Site ID, can be found below',
},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: true,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
name: 'Bloomberg Site',
maintainers: ['bigfei'],
description: `
| Site ID | Title |
| ------------ | ------------ |
| / | News |
| bpol | Politics |
| bbiz | Business |
| markets | Markets |
| technology | Technology |
| green | Green |
| wealth | Wealth |
| pursuits | Pursuits |
| bview | Opinion |
| equality | Equality |
| businessweek | Businessweek |
| citylab | CityLab |
`,
handler,
};
async function handler(ctx) {
const site = ctx.req.param('site');
const currentUrl = site ? `${rootUrl}/${site}/sitemap_news.xml` : `${rootUrl}/sitemap_news.xml`;
const list = await parseNewsList(currentUrl, ctx);
const items = await asyncPoolAll(1, list, (item) => parseArticle(item));
return {
title: `Bloomberg - ${site_title_mapping[site ?? '/']}`,
link: currentUrl,
item: items,
};
}