Last active
October 11, 2021 16:43
-
-
Save hpr/e6461ecf890a1a7c69d8619f72c0a621 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 pprint | |
import datetime | |
# https://results.chicagomarathon.com/2021/?content=ajax2&func=getLeaderboard&onpageleaderboard | |
r = requests.post('https://boston-iframe.r.mikatiming.net/2021/?content=ajax2&func=getLeaderboard&onpageleaderboard', data = { | |
'options[option_bar][limit]': 100 | |
}).json() | |
MEN = 0 | |
WOMEN = 2 | |
csv = True | |
splits = {} | |
for gen in [WOMEN]: | |
if gen == MEN: print('MEN') | |
else: print('WOMEN') | |
for i, split in enumerate(r['containers'][gen]['data']['rows']): | |
if i < 4: | |
kilos = (i+1)*5 | |
if not csv: print(str(kilos) + 'K') | |
elif i == 4: | |
kilos = 42.195/2 | |
if not csv: print('HALF') | |
elif i == 7: | |
kilos = 1.609344 * 20 | |
if not csv: print('20 MILES') | |
elif i == 8: | |
kilos = 1.609344 * 21 | |
if not csv: print('21 MILES') | |
elif i == 9: | |
kilos = 35 | |
if not csv: print('35K') | |
elif i == 10: | |
kilos = 40 | |
if not csv: print('40K') | |
elif i == 11: | |
kilos = 42.195 - 1.609344 | |
if not csv: print('25.2 MILES') | |
elif i == 12: | |
kilos = 42.195 | |
if not csv: print('FINISH') | |
# elif i == 9: | |
# kilos = 42.195 | |
# print('FINISH') | |
else: | |
kilos = i*5 | |
if not csv: print(str(kilos) + 'K') | |
for j, ath in enumerate(split): | |
name = ath['__fullname'] | |
if name not in splits: splits[name] = {} | |
h, m, s = ath['actual_split_time'].split(':') | |
cursplit = datetime.timedelta(hours = int(h), minutes = int(m), seconds = int(s)) | |
# pace = distance / speed | |
# speed = distance / secs | |
speed = kilos / cursplit.total_seconds() | |
pace = datetime.timedelta(seconds = int(42.195 / speed)) | |
splits[name][i] = cursplit | |
if i-1 in splits[name]: | |
if csv: | |
print(','.join([str(kilos),str(j+1),'"'+ath['__fullname']+'"',ath['actual_split_time'],str(cursplit - splits[name][i-1]),str(pace)])) | |
else: | |
print(str(j+1) + '.', ath['__fullname'], ath['actual_split_time'], '-', cursplit - splits[name][i-1], '('+str(pace)+')') | |
else: | |
if csv: | |
print(','.join([str(kilos),str(j+1),'"'+ath['__fullname']+'"',ath['actual_split_time'],'',str(pace)])) | |
else: | |
print(str(j+1) + '.', ath['__fullname'], ath['actual_split_time'], '('+str(pace)+')') | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment