def mercatox():
http = urllib3.PoolManager(cert_reqs='CERT_REQUIRED',ca_certs=certifi.where())
url = 'https://mercatox.com/public/json24'
#response = http.request('GET', url, headers=header, timeout=20.0)
response = http.request('GET', url, timeout=20.0)
json_mercatox = json.loads(response.data)
json_array = json_mercatox['pairs']['XRB_BTC']
try:
last_price = int(float(json_array['last']) * (10 ** 8))
except KeyError:
last_price = 0
high_price = int(float(json_array['high24hr']) * (10 ** 8))
low_price = int(float(json_array['low24hr']) * (10 ** 8))
ask_price = int(float(json_array['lowestAsk']) * (10 ** 8))
bid_price = int(float(json_array['highestBid']) * (10 ** 8))
volume = int(float(json_array['baseVolume']))
btc_volume = int(float(json_array['quoteVolume']) * (10 ** 8))
mysql_set_price(1, last_price, high_price, low_price, ask_price, bid_price, volume, btc_volume)
评论列表
文章目录