-
Notifications
You must be signed in to change notification settings - Fork 1
/
doordash.py
69 lines (52 loc) · 2.13 KB
/
doordash.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
import requests
import time
import json
import random
def doordash_scraper():
# Define the URL
# Get the current timestamp in milliseconds
current_timestamp = int(time.time() * 1000)
# Generate a random number between 1 and 1000
random_number = random.randint(1, 1000)
# Combine the timestamp and random number to create a unique identifier
unique_identifier = f"{current_timestamp}-{random_number}"
# Define the URL with the unique identifier appended
url = f"https://boards-api.greenhouse.io/v1/boards/doordash/departments?timestamp={unique_identifier}"
# Make your request using the URL
response = requests.get(url)
# Check the response status code
print("Response Status Code:", response.status_code)
data = response.text
states = ["AK", "AL", "AR", "AZ", "CA", "CO", "CT", "DE", "FL", "GA", "HI", "IA",
"ID", "IL", "IN", "KS", "KY", "LA", "MA", "MD", "ME", "MI", "MN", "MO",
"MS", "MT", "NC", "ND", "NE", "NH", "NJ", "NM", "NV", "NY", "OH", "OK",
"OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VA", "VT", "WA", "WI",
"WV", "WY", "DC", "USA", "United States"]
# Add a space before each initial
states_with_space = [' ' + state for state in states]
list1 = []
data = json.loads(data)
for job in data["departments"]:
if job["jobs"]:
for i in job["jobs"]:
item = {}
item['role'] = i['title']
item['link'] = i['absolute_url']
item['company'] = "Doordash"
item['location'] = i['location']['name']
list1.append(item)
new_list = []
for job in list1:
if "intern" in job["role"].lower():
new_list.append(job)
new_list2 = []
for job in new_list:
bool1 = False
for i in states_with_space:
if i in job["location"]:
bool1 = True
if bool1:
new_list2.append(job)
return new_list2
if __name__ == "__main__":
print(doordash_scraper())