import requests from datetime import datetime URL = "https://min-api.cryptocompare.com/data/price?fsym={}&tsyms={}" def get_price(coin, currency): try: response = requests.get(URL.format(coin, currency)).json() return response except: return False while True: date_time = datetime.now() date_time = date_time.strftime("%d/%m/%Y %H:%M:%S") currentPrice = get_price("BTC", "USD") if currentPrice: print(date_time, "$", currentPrice["USD"])
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter