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)