-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhide_profiles.py
46 lines (38 loc) · 1.34 KB
/
hide_profiles.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
import pandas as pd
import json
import requests
import sys
def main():
print(sys.argv)
API_KEY = sys.argv[1]
JOBBOARD_API_KEY = sys.argv[2]
owner = 'VectorInstitute'
repo = 'Vector-Jobboard'
path = 'OldProfiles_ProfilesExport.csv'
branchName = 'gh-pages'
url = f"https://api.github.com/repos/{owner}/{repo}/contents/{path}?ref={branchName}"
response = requests.get(url, headers = { "Authorization": "Bearer " + API_KEY})
data = response.json()
csvUrl = data['download_url']
df = pd.read_csv(csvUrl)
x = df.iloc[:, 0].values
headers = {
"Accept": "application/json",
"JobBoardioURL": "https://talenthub.vectorinstitute.ai/",
"X-Api-Key" : JOBBOARD_API_KEY
}
for ID in range(len(x)):
url = "https://canadaai.jobboard.io/api/v1/profiles/" + str(x[ID])
response = requests.request("GET", url, headers=headers)
data = json.loads(response.text)
try:
if data['profile']['hidden'] or data['profile']['hidden'] == 'True':
continue
except:
continue
payload = {"hidden": True}
response = requests.request("PATCH", url, json=payload, headers=headers)
response = requests.request("GET", url, headers=headers)
data = json.loads(response.text)
if __name__ == "__main__":
main()