/
jobs.ts
55 lines (48 loc) · 1.4 KB
/
jobs.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
import { Route } from '@/types';
import got from '@/utils/got';
import { load } from 'cheerio';
const rootUrl = 'https://jobs.douban.com';
const titleMap = {
social: '社会招聘',
campus: '校园招聘',
intern: '实习生招聘',
};
export const route: Route = {
path: '/jobs/:type',
categories: ['social-media'],
example: '/douban/jobs/campus',
parameters: { type: '招聘类型,见下表' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
name: '豆瓣招聘',
maintainers: ['Fatpandac'],
handler,
description: `| 社会招聘 | 校园招聘 | 实习生招聘 |
| :------: | :------: | :--------: |
| social | campus | intern |`,
};
async function handler(ctx) {
const type = ctx.req.param('type');
const url = `${rootUrl}/jobs/${type}`;
const response = await got.get(url);
const $ = load(response.data);
const list = $('div.mod.position');
const items = list
.map((_, item) => ({
title: $(item).find('h3').text(),
link: `${url}#${$(item).find('h3').attr('id')}`,
description: $(item).find('div.bd').html(),
}))
.get();
return {
title: `豆瓣${titleMap[type]}`,
link: url,
item: items,
};
}