#!/usr/bin/python3.6

import requests, json, datetime
from time import sleep

try:
  while True:
    req = requests.get('https://www.mercadobitcoin.net/api/BTC/ticker/')
    cot = json.loads(req.text)
    d = datetime.datetime.now()
    print(d.strftime('%c'))
    print('BTC:', cot['ticker']['buy'][:8])
    sleep(10)
    print('')

except:
  print("Failed to establish a connection.")
