Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import urllib.request
- import json
- import time
- import sys
- a = []
- b = []
- s = ""
- handle = "pikmike"
- with urllib.request.urlopen("http://codeforces.com/api/user.rating?handle=" + handle) as response:
- html = str(response.read())[2:-1].replace('\\x', '.')
- while ('\\\\"' in html):
- html = html.replace('\\\\"', ".")
- s = html
- while ("contestId" in s):
- pos = s.index("contestId") + len("contestId") + 2
- s = s[pos:]
- a.append([s[:3], 0])
- pos = s.index("rank") + len("rank") + 2
- s = s[pos:]
- a[-1][1] = s[:s.index(',')]
- res = []
- for contest in a:
- sys.stderr.write(contest[0] + " " + contest[1] + "\n")
- sys.stderr.flush()
- with urllib.request.urlopen("http://codeforces.com/api/contest.standings?contestId=" + contest[0] + "&from=" + contest[1] + "&count=10000&showUnofficial=false") as response:
- html = str(response.read())[2:-1].replace('\\x', '.')
- while ('\\\\"' in html):
- html = html.replace('\\\\"', ".")
- tmp = json.loads(html)["result"]["rows"]
- for part in tmp:
- if (part["party"]["members"][0]["handle"] == "PikMike"):
- res.append([int(part["successfulHackCount"]), int(part["unsuccessfulHackCount"])])
- break
- time.sleep(0.3)
- #print(res)
- s = 0
- t = 0
- for i in res:
- s += i[0]
- t += i[1]
- print("+" + str(s) + ":-" + str(t))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement