Skip to content

Instantly share code, notes, and snippets.

@myano
Created July 1, 2015 17:46
Show Gist options
  • Save myano/33e8c5d5344591cf767e to your computer and use it in GitHub Desktop.
Save myano/33e8c5d5344591cf767e to your computer and use it in GitHub Desktop.
def greece(jenni, input):
if not input.admin:
return jenni.say('Please obtain admin-privs to use this function.')
url = 'https://www.indiegogo.com/projects/greek-bailout-fund#/story'
try:
page = web.get(url)
except:
return jenni.say('Could not connect to indiegogo.com')
find_euros = re.compile(r"<div class='i-balance'><span class=\"currency currency-xlarge\"><span>(\S+)</span><em>EUR</em></span></div>")
results = find_euros.findall(page)
if results:
jenni.say(results[0])
else:
jenni.say('Could not find donation amount.')
greece.commands = ['greece']
greece.rate = 300
@sbp
Copy link

sbp commented Jul 1, 2015

saxo style:

#!/usr/bin/env python3

import re
import saxo

p = r'<span class="currency currency-xlarge"><span>(\S+)</span><em>EUR</em>'

@saxo.command()
def greece(arg):
    url = "https://www.indiegogo.com/projects/greek-bailout-fund"
    page = saxo.request(url)
    for result in re.compile(p).findall(page["text"]):
        return result
    return "Could not find donation amount"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment