Last active
August 29, 2015 14:23
-
-
Save mdavey/fe57d569cdb77bdd52b8 to your computer and use it in GitHub Desktop.
wow we suck
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
__author__ = 'Matthew' | |
import re | |
import urllib | |
def parse_reportlist(filename): | |
counter = 999 | |
urls = [] | |
with open(filename, 'r') as f: | |
matches = re.findall('<a href="https://www.warcraftlogs.com/reports/([a-zA-Z0-9]+)">([^<]+)</a>', f.read()) | |
for match in matches: | |
urls.append((str(counter) + '_' + match[0], 'https://www.warcraftlogs.com/reports/fights_and_participants/' + match[0] + '/0')) | |
counter -= 1 | |
return urls | |
def download(url, dest): | |
print 'Saving', url, 'to', dest, | |
with open(dest, 'w+') as f: | |
f.write(urllib.urlopen(url).read()) | |
print 'Done' | |
for (id, url) in parse_reportlist('reportlist.html'): | |
download(url, 'reports/' + id + '.html') |
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
__author__ = 'Matthew' | |
import glob | |
import json | |
def parse_report(filename): | |
data = json.loads(open(filename).read()) | |
for fight in data['fights']: | |
if fight['boss'] == 0: | |
continue | |
if fight['difficulty'] != 5: | |
continue | |
yield {'name': fight['name'], 'length': (fight['end_time'] - fight['start_time']) / 1000, 'kill': fight['kill']} | |
for filename in glob.glob('reports/*.html'): | |
for fight in parse_report(filename): | |
if fight['name'] == 'Brackenspore': | |
if fight['kill']: | |
print '--------DONE---------' | |
else: | |
print fight['length'] | |
# Results: https://project-2501.net/gallery/wow/2015-0202%20brakenspore-attempt-length.png |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment