Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #python 3
- import time
- import hashlib
- import random,json
- #pip install requests
- import requests
- #function to get current time in unix format
- current_milli_time = lambda: int(round(time.time() * 1000))
- apikey="xxxxxxxxxx"
- secret="xxxxxxxxxx"
- curTime=current_milli_time()
- rand = random.randint(100000,900000)
- api="http://codeforces.com/api/"
- method="contest.standings?"
- contestId="566"
- hash="%s/%sapiKey=%s&contestId=%s&time=%s#%s"%(rand, method, apikey, contestId, curTime, secret)
- hash=hashlib.sha512(("%s"%(hash)).encode('utf-8')).hexdigest()
- arg="contestId=%s&apiKey=%s&time=%s&apiSig=%s%s"%(contestId, apikey, curTime, rand, hash)
- #print (api+method+arg)
- req= requests.get(api+method+arg)
- print(req.json())
Add Comment
Please, Sign In to add comment