Bitcoin Speech Price Tracker
Date: December 4, 2014
Categories: Python
simple python script
to bitcoin price speech is the target price reached
it takes argument 1 as a target price
simple but still useful
to monitor bitcoin price via speech
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
#!/usr/bin/env python import json import urllib2 import sys import os import time import datetime i = 0 while True: link = "https://btc-e.com/api/2/btc_usd/ticker/" try: content = urllib2.urlopen(link) data_out = json.loads(content.read()) last = data_out['ticker']['last'] except: time.sleep(3) os.system("espeak 'connection lost'") continue i += 1 if int(last) >= int(sys.argv[1]): os.system("espeak wakeup") cli = "notify-send 'the current price is : %s'" %last os.system(cli) print last print "Target : " + str(sys.argv[1]) + " Last: " + str(last) + " DateTime: " + str(datetime.datetime.now()) if i == 10: cli = "notify-send 'the current price is : %s'" %last os.system(cli) i = 0 time.sleep(9) |
Leave a Reply