SorahISA

api.py

Jun 7th, 2021 (edited)
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. import requests, json
  2. from time import time
  3. from urllib.parse import urlencode
  4. from hashlib import sha512
  5.  
  6. if __name__ == '__main__':
  7.     key = 'owo' # CHANGE IT
  8.     secret = 'owo' # CHANGE IT
  9.     contestId = int(input("contestId: "))
  10.     data = urlencode({
  11.         'apiKey': key,
  12.         'contestId': contestId,
  13.         # 'count': count,
  14.         # 'from': 1,
  15.         'time': int(time())
  16.     })
  17.     methods = 'contest.status'
  18.     apiSig = sha512(f'123456/{methods}?{data}#{secret}'.encode()).hexdigest()
  19.  
  20.     res = requests.get(f'https://codeforces.com/api/{methods}?{data}',params={'apiSig':'123456'+apiSig})
  21.     # print(res)
  22.     print(res.url)
  23.     print(json.loads(res.text))
  24.  
Add Comment
Please, Sign In to add comment