Created
September 27, 2015 12:12
-
-
Save corpix/8fdf9ca481da3004714c to your computer and use it in GitHub Desktop.
heroku logsaver
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
# -*- coding: utf-8 -*- | |
from __future__ import print_function | |
import requests | |
from lxml import html | |
import json | |
import sys | |
import os | |
HOST = "http://lumber.leanpoker.org" | |
SOURCE = HOST + "/logs/tournament/55e4be2d4adaaf0003000002/team/poker-player-abuse-or-lose/log" | |
r = requests.get(SOURCE) | |
text = r.text | |
tree = html.fromstring(text) | |
uris = [] | |
for a in tree.xpath('//a'): | |
uri = a.get("href") | |
if uri and len(uri): | |
uris.append(HOST + uri) | |
for uri in reversed(uris): | |
name = os.path.basename(uri) | |
if not os.path.exists(name): | |
print("#getting", name) | |
with open(name, "w+") as fd: | |
fd.write(requests.get(uri).text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment