-
-
Save johnsardine/ac67383795575063e8098c0e56574e44 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, re | |
problem_name = 'even-or-odd' | |
problem_url = 'https://www.codewars.com/kata/' + problem_name | |
users = [ 'fabiopedrosa', 'johnsardine', 'disbeat', 'pgcmarques', 'nnunobm', 'alexp100' ] | |
problem_id = re.findall('<div class="info-row code-challenge" data-id="(.+?)"', requests.get(problem_url).text)[0] | |
users = dict( [ (u, []) for u in users ] ) | |
for user in users: | |
token = None | |
cids = {} | |
for page in range(0, 100): | |
url = "https://www.codewars.com/users/%s/completed?page=%d" % (user, page) | |
r = requests.get(url, headers = { 'x-requested-with': 'XMLHttpRequest', 'x-csrf-token': token }) | |
if token == None: token = re.findall('content\="(.+?)" name="csrf-token"', r.text)[0] | |
pids = re.findall("data\-id=\"(.+?)\"", r.text) | |
if len(pids) == 0: break | |
for cid in pids: cids[cid] = True | |
print "\t=> %s has solved %d problems" % (user, len(cids)) | |
users[user] = cids | |
print "*%s* (%s)" % ( problem_name, problem_url ) | |
for user in users.keys(): | |
print user, "Yep!" if problem_id in users[user] else "Nop" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment