-
Notifications
You must be signed in to change notification settings - Fork 0
/
tesla.py
64 lines (47 loc) · 1.69 KB
/
tesla.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
import requests
from pprint import pprint
url = "https://www.tesla.com/cua-api/apps/careers/state"
r = requests.get(url)
data = r.json()
# get all locations in a country
def getLocations(_country='FR', _region='3'):
# regions = data['lookup']['regions']
# countries = data['lookup']['countries']
# locations = data['lookup']['locations']
# departments = data['lookup']['departments']
# types = data['lookup']['types']
locations = []
# select only the specified region
for region in data['geo']:
if region['id'] == _region:
# select only the specified country
for country in region['sites']:
if country['id'] == _country:
# get all the locations in the specified country
for city in country['cities'].values():
for location in city:
locations.append(location)
return locations
# get all internships in a country
def getInternships(_country='FR', _region='3'):
locations = getLocations(_country, _region)
listings = data['listings']
internships = [
listing
for listing in listings
# select only internships in France
if listing['y'] == 3 and listing['l'] in locations
]
return internships
def getInternshipInfos(id):
return requests.get(
f'https://www.tesla.com/cua-api/careers/job/{id}').json()
if __name__ == '__main__':
country = 'FR'
region = '3'
internships = getInternships(country, region)
if len(internships):
for internship in internships:
pprint(getInternshipInfos(internship['id']))
else:
print('No new internships')