forked from bundesAPI/jobsuche-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi_example.py
More file actions
52 lines (42 loc) · 1.67 KB
/
api_example.py
File metadata and controls
52 lines (42 loc) · 1.67 KB
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
import requests
import base64
def get_jwt():
"""fetch the jwt token object"""
headers = {
'User-Agent': 'Jobsuche/2.9.2 (de.arbeitsagentur.jobboerse; build:1077; iOS 15.1.0) Alamofire/5.4.4',
'Host': 'rest.arbeitsagentur.de',
'Connection': 'keep-alive',
'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
}
data = {
'client_id': 'c003a37f-024f-462a-b36d-b001be4cd24a',
'client_secret': '32a39620-32b3-4307-9aa1-511e3d7f48a8',
'grant_type': 'client_credentials'
}
response = requests.post('https://rest.arbeitsagentur.de/oauth/gettoken_cc', headers=headers, data=data, verify=False)
return response.json()
def search(jwt, what, where):
"""search for jobs. params can be found here: https://jobsuche.api.bund.dev/"""
params = (
('angebotsart', '1'),
('page', '1'),
('pav', 'false'),
('size', '100'),
('umkreis', '25'),
('was', what),
('wo', where),
)
headers = {
'User-Agent': 'Jobsuche/2.9.2 (de.arbeitsagentur.jobboerse; build:1077; iOS 15.1.0) Alamofire/5.4.4',
'Host': 'rest.arbeitsagentur.de',
'OAuthAccessToken': jwt,
'Connection': 'keep-alive',
}
response = requests.get('https://rest.arbeitsagentur.de/jobboerse/jobsuche-service/pc/v4/app/jobs',
headers=headers, params=params, verify=False)
return response.json()
if __name__ == "__main__":
jwt = get_jwt()
result = search(jwt["access_token"], "bahn", "berlin")
print(result['stellenangebote'][0]["refnr"])
print(job_details(jwt["access_token"], result['stellenangebote'][0]["refnr"]))