-
Notifications
You must be signed in to change notification settings - Fork 0
/
jobvite-public.py
executable file
·103 lines (82 loc) · 3.2 KB
/
jobvite-public.py
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/env python3
import requests
import xmltodict
COMPANY_ID = 'qyy9VfwU'
COMPANY_NAME = 'InnoGames'
JOBVITE_XML = 'https://app.jobvite.com/CompanyJobs/Xml.aspx?c={}&cf=e'.format(
COMPANY_ID)
CATEGORIES = ['Development',
'Quality Assurance',
'System Administration',
'Office IT']
CATEGORIES_ALL = ['Analytics']
CUSTOM_SUB_CATEGORIES_ALL = ['Development & IT']
CUSTOM_SUB_CATEGORIES_CAT_ONLY = ['Career Starters']
JOBVITE_SOURCE_TYPE = 'Job+Board'
JOBVITE_SOURCE_DETAIL = 'github_jobs_repo'
HOMEPAGE_BASE = 'https://www.innogames.com/career/detail/job'
JOBVITE_DIRECT = 'https://jobs.jobvite.com/careers/innogames/job'
TEASER_TEXT='# Open Positions @ [InnoGames]({}?s={})\n\n'.format(
HOMEPAGE_BASE, JOBVITE_SOURCE_DETAIL)
def get_listings():
r = requests.get(JOBVITE_XML, stream=True)
jobs = xmltodict.parse(r.text)
return(dict(jobs))
def sanitize_url(input_str, dedup_char, offset=0, out=''):
for i in [' ', '[', ']', '(', ')', '/', '\\', '?', '*', ':']:
input_str = input_str.replace(i, '-')
for c in input_str:
if offset > 0 and c == dedup_char and out[offset - 1] == dedup_char:
continue
else:
out += c
offset += 1
return out
def get_homepage_url(job):
url = HOMEPAGE_BASE
sanitized = sanitize_url(job['title'], '-').lower()
url = HOMEPAGE_BASE + '/' + sanitized + '/'
return(url)
def render_job(job):
rendered = '<h1>{}</h1>\n'.format(job['title'])
rendered += job['description']
rendered += '\n\n<h2><a href="{}/{}/apply?__jvst={}&__jvsd={}">Apply Now</a> ' \
'directly or get more <a href="{}?s={}">Information</a> about {}</h2>'.format(
JOBVITE_DIRECT,
job['id'],
JOBVITE_SOURCE_TYPE,
JOBVITE_SOURCE_DETAIL,
get_homepage_url(job),
JOBVITE_SOURCE_DETAIL,
COMPANY_NAME)
return(rendered)
def render_readme(jobs):
markdown = TEASER_TEXT
for job in jobs['result']['job']:
if job['subcategory'] in CUSTOM_SUB_CATEGORIES_ALL or (
job['category'] in CATEGORIES_ALL ) or (
job['subcategory'] in CUSTOM_SUB_CATEGORIES_CAT_ONLY and
job['category'] in CATEGORIES):
filename = sanitize_url(
job['title'], '-').strip('-').lower() + '.md'
markdown += '### [{}]({})\n'.format(
job['title'].replace('(', '\(').replace(')', '\)'),
filename)
return(markdown)
def main():
jobs = get_listings()
for job in jobs['result']['job']:
if job['subcategory'] in CUSTOM_SUB_CATEGORIES_ALL or (
job['category'] in CATEGORIES_ALL ) or (
job['subcategory'] in CUSTOM_SUB_CATEGORIES_CAT_ONLY and
job['category'] in CATEGORIES):
filename = sanitize_url(
job['title'], '-').strip('-').lower() + '.md'
f = open(filename, 'w')
f.write(render_job(job))
f.close()
f = open('README.md', 'w')
f.write(render_readme(jobs))
f.close()
if __name__ == '__main__':
main()