Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

CryptoPrice

Hloody Jun 6th, 2018 (edited) 16 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. import pifacecad, time, json, requests
  2.  
  3. price = 0
  4.  
  5. cad = pifacecad.PiFaceCAD()
  6. cad.lcd.backlight_on()
  7. cad.lcd.blink_off()
  8. cad.lcd.cursor_off()
  9.  
  10. cryptos = ["Bitcoin","Monero","Ethereum","Steem"]
  11.  
  12. def getprice(cryptoz):
  13.         link = 'https://api.coinmarketcap.com/v1/ticker/' + cryptoz.lower() +'/'
  14.         request = requests.get(link)
  15.  
  16.         price = request.json()
  17.         price = price[0]["price_usd"]
  18.  
  19.         price2 = price.split(".")
  20.  
  21.         price = price2[0] + "." + price2[1][:2]
  22.  
  23.         print(cryptoz + ": " + price)
  24.         return price
  25.  
  26. def writeprice(cryptoz):
  27.         cad.lcd.clear()
  28.         cad.lcd.write(cryptoz)
  29.         cad.lcd.set_cursor(1,1)
  30.  
  31.         price = getprice(cryptoz)
  32.  
  33.         cad.lcd.write(str(price) + " $")
  34.  
  35. while True:
  36.     for cr in cryptos:
  37.         try:
  38.             writeprice(cr)
  39.         except:
  40.             cad.lcd.write("Error")
  41.         time.sleep(10)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top