Created
November 19, 2013 10:05
-
-
Save daGrevis/7543107 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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