Skip to content

Instantly share code, notes, and snippets.

@daGrevis
Created November 19, 2013 10:05
Show Gist options
  • Select an option

  • Save daGrevis/7543107 to your computer and use it in GitHub Desktop.

Select an option

Save daGrevis/7543107 to your computer and use it in GitHub Desktop.
import requests
import json
import envelopes
import time
DATA_URL = "http://blockchain.info/ticker"
EMAIL_ADDR = "dagrevis@gmail.com"
INTERVAL_S = 60 * 60
try:
while True:
data = requests.get(DATA_URL)
data = json.loads(data.content)
price = data["USD"]["last"]
envelope = envelopes.Envelope(
from_addr=("localhost",),
to_addr=EMAIL_ADDR,
subject="Bitcoin Price",
text_body="1 BTC is {} USD.".format(price),
)
envelope.send("localhost")
print("Message sent!")
time.sleep(INTERVAL_S)
except KeyboardInterrupt:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment