Last active
May 18, 2016 00:49
-
-
Save bigomega/b37ca34c4b635008215788b0f1cc89cc to your computer and use it in GitHub Desktop.
Dota International 2016 PrizePool scraper
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 urllib2, re, time, json, os | |
import gspread | |
from oauth2client.client import SignedJwtAssertionCredentials | |
html = urllib2.urlopen('http://www.dota2.com/international/battlepass').read() | |
prizepool = re.search('id=[\'"]prizepool[^>]*>[\n\r\t]*([^<\t\r\n]*)', html, re.IGNORECASE).group(1) | |
print(time.strftime('%H:%M - %m/%d/%Y'), prizepool) | |
print("Update it in Google sheets") | |
json_key = json.load(open(os.path.join(os.path.dirname(__file__), 'Personal hacks-0e20089bab35.json'))) | |
scope = ['https://spreadsheets.google.com/feeds'] | |
credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'].encode(), scope) | |
gc = gspread.authorize(credentials) | |
wks = gc.open_by_key('1wwsNgSWd1mTv9BF1NqHCowjRIGKF8YVFFxLLeQGUUM4').worksheet('Data') | |
# wks = gc.open('Balance Tracker').get_worksheet(0) | |
cell = wks.acell('J1').value | |
wks.update_acell('A' + cell, time.strftime('%H:%M')) | |
wks.update_acell('B' + cell, time.strftime('%m/%d/%Y')) | |
wks.update_acell('C' + cell, prizepool) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment