-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfuture.py
62 lines (59 loc) · 2.06 KB
/
future.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
#Import Dependencies
import requests,ast, json
from requests_oauthlib import OAuth1
from datetime import datetime,date,time
#URL - response
url = "https://clist.by/api/v1/json/contest//?"+YOUR_API_KEY
payload = "{}"
response = requests.request("GET",url,data=payload)
a = response.text
parsed_json = json.loads(a)
total = parsed_json['meta']['total_count']
total = str(total)
j_count = int(total[:2])
today = datetime.today().day
toyear = datetime.today().year
tomonth = datetime.today().month
count = 0
for j in range(j_count+1):
k = str(j*1000)
url = "https://clist.by/api/v1/json/contest/?limit="+total+"&offset="+k+"YOUR_API_KEY"
payload = "{}"
response = requests.request("GET",url,data=payload)
print("OFFSET:",k,"\n","RESPONSE:",response,"\n\n")
a = response.text
parsed_json = json.loads(a)
if j == j_count:
print("INSIDE END")
for i in range(int(total) - int(k)):
startyear = int(parsed_json['objects'][i]['start'][:4])
startmonth = int(parsed_json['objects'][i]['start'][5:7])
startday = int(parsed_json['objects'][i]['start'][8:10])
if startyear > toyear:
print("Event:",i,"=",parsed_json['objects'][i])
count+=1
elif startyear == toyear:
if startmonth > tomonth:
print("Event:",i,"=",parsed_json['objects'][i])
count+=1
elif startmonth == tomonth:
if startday > today:
print("Event:",i,"=",parsed_json['objects'][i])
count+=1
else:
for i in range(1000):
startyear = int(parsed_json['objects'][i]['start'][:4])
startmonth = int(parsed_json['objects'][i]['start'][5:7])
startday = int(parsed_json['objects'][i]['start'][8:10])
if startyear > toyear:
print("Event:",i,"=",parsed_json['objects'][i])
count+=1
elif startyear == toyear:
if startmonth > tomonth:
print("Event:",i,"=",parsed_json['objects'][i])
count+=1
elif startmonth == tomonth:
if startday > today:
print("Event:",i,"=",parsed_json['objects'][i])
count+=1
print(count)