-
Notifications
You must be signed in to change notification settings - Fork 1
/
contestretreiverapi.py
40 lines (26 loc) · 1008 Bytes
/
contestretreiverapi.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
import requests
import json
from datetime import date
today=date.today()
#print(str(today))
#print("https://clist.by:443/api/v1/contest/?start__gte="+ str(today) +"T00%3A00%3A00&order_by=start&username=nishitsharm03&api_key=34bb37ac0dc7d26189a9b939cb2a5ab55ae584a0")
result= requests.get("https://clist.by:443/api/v1/contest/?start__gte=" + str(today) +"T00%3A00%3A00&order_by=start&username=nishitsharm03&api_key=34bb37ac0dc7d26189a9b939cb2a5ab55ae584a0")
if result.status_code!=200:
print('Unable to get data')
exit()
res=json.loads(result.content.decode('utf-8'));
# print(type(result))
contests=res['objects']
print(type(contests))
names=['codechef.com','hackerearth.com','codeforces.com','leetcode.com','atcoder.com']
finallist={}
cnt=0
for i in contests:
if i['resource']['name'] in names:
i['duration']//=60
print(i, type(i))
finallist[cnt]=i
cnt+=1;
with open('data.json','w') as outfile:
# for i in res:
json.dump(finallist,outfile)