#!/usr/bin/env python
# -*- coding: utf-8 -*-
import websocket
import json
import datetime,time
"""
Python 2.x
sudo pip install websocket-client
Python 3.x
sudo pip3 install websocket-client
"""
websocket.enableTrace(False)
eurPrice=0
try:
# connect to the wss server
ws = websocket.create_connection("wss://www.goldmoney.com/ws/exchange-rates")
# get data
data=ws.recv_data()
# get dollar price
price=json.loads(data[1])["rates"]["GAU"]
# get conversión to EUR
eur=json.loads(data[1])["rates"]["EUR"]
eurPrice=price/eur
ws.close()
print(eurPrice)
except websocket._exceptions.WebSocketBadStatusException:
print("Connecting to websocket: Error 403")
except:
print("Connecting to websocket: No connection")
Comentarios sobre la versión: 1.0 (0)
No hay comentarios