Skip to content

Instantly share code, notes, and snippets.

@bigomega
Last active May 18, 2016 00:49
Show Gist options
  • Select an option

  • Save bigomega/b37ca34c4b635008215788b0f1cc89cc to your computer and use it in GitHub Desktop.

Select an option

Save bigomega/b37ca34c4b635008215788b0f1cc89cc to your computer and use it in GitHub Desktop.

Revisions

  1. bigomega revised this gist May 18, 2016. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions mini_scraper.py
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@

    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 %Z - %m/%d/%Y'), prizepool)
    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')))
    @@ -14,6 +14,6 @@
    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 %Z'))
    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)
  2. bigomega revised this gist May 18, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mini_scraper.py
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    import urllib2, re, time
    import urllib2, re, time, json, os
    import gspread
    from oauth2client.client import SignedJwtAssertionCredentials

  3. bigomega revised this gist May 17, 2016. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions mini_scraper.py
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,7 @@

    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 %Z - %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')))
  4. bigomega created this gist May 17, 2016.
    18 changes: 18 additions & 0 deletions mini_scraper.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    import urllib2, re, time
    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("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 %Z'))
    wks.update_acell('B' + cell, time.strftime('%m/%d/%Y'))
    wks.update_acell('C' + cell, prizepool)