Created
April 14, 2017 20:40
-
-
Save LiveOverflow/e727511a7ec3a3dad808213a1074863e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import re | |
import operator | |
def get_scoreboard(): | |
r = requests.get('http://rhme.riscure.com/scores') | |
return re.findall(r'<a href="user\?id=([0-9]+)">', r.text) | |
def get_solved(uid): | |
r = requests.get('http://rhme.riscure.com/user?id={}'.format(uid)) | |
return re.findall(r'<a href="http://rhme.riscure.com/challenge\?id=([0-9]+)">\n(.+)\n.+', r.text) | |
solved = {} | |
challs = {} | |
for uid in get_scoreboard(): | |
print "User {}".format(uid) | |
solved_challs = get_solved(uid) | |
if not solved_challs: | |
break | |
for chall in solved_challs: | |
cid, name = chall | |
if cid not in solved: | |
challs[cid] = name.strip() | |
solved[cid] = 0 | |
solved[cid] += 1 | |
print challs[cid], solved[cid] | |
print "\nSorted Scoreboard:" | |
solved_sorted = sorted(solved.items(), key=operator.itemgetter(1)) | |
for cid, nr_solved in solved_sorted[::-1]: | |
print "{} ({} solves) - http://rhme.riscure.com/challenge?id={}".format(challs[cid], nr_solved, cid) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment