Skip to content

Instantly share code, notes, and snippets.

@LiveOverflow
Created April 14, 2017 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LiveOverflow/e727511a7ec3a3dad808213a1074863e to your computer and use it in GitHub Desktop.
Save LiveOverflow/e727511a7ec3a3dad808213a1074863e to your computer and use it in GitHub Desktop.
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