Skip to content

Instantly share code, notes, and snippets.

@mdavey
Last active August 29, 2015 14:23
Show Gist options
  • Save mdavey/fe57d569cdb77bdd52b8 to your computer and use it in GitHub Desktop.
Save mdavey/fe57d569cdb77bdd52b8 to your computer and use it in GitHub Desktop.
wow we suck
__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')
__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