Skip to content

Instantly share code, notes, and snippets.

@marocchino
Forked from starmomo/gist:6364460
Created August 28, 2013 11:52
Show Gist options
  • Save marocchino/6365169 to your computer and use it in GitHub Desktop.
Save marocchino/6365169 to your computer and use it in GitHub Desktop.
import sys
import tweepy
import time
import urllib2
def send_to_twitter(msg):
CONSUMER_KEY = 'UvciBAguVW4UBYBkWeirKg'
CONSUMER_SECRET = 'eCPMIB4sMUDTfTExohS5PyzlIKMFGpWprMbgINqhU'
ACCESS_KEY = '196057523-d2RNDmy3YE5b5v0L59EKfYGIOS31Q9iEdLNdyE1u'
ACCESS_SECRET = 'Dvlg8M7HhS3DdJVjI13CBllFel1Ke9uhEv6VgbIoXg'
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
api = tweepy.API(auth)
api.update_status(msg)
def get_price():
page = urllib2.urlopen("http://beans.itcarlow.ie/prices-loyalty.html")
text = page.read().decode("utf8")
where = text.find('>$')
start_of_price = where + 2
end_of_price = start_of_price + 4
return float(text[start_of_price:end_of_price])
price_now = raw_input("Do you want to see the price now (Y/N)? ")
print get_price()
if price_now == "Y":
print get_price()
send_to_twitter(get_price())
else:
price = 99.99
while price > 4.74:
time.sleep(900)
price = get_price()
send_to_twitter("Buy!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment