# ! / usr / bin / env python
# - * - encoding : utf ] [1965]]
import websocket
import json
import datetime time
]]
[]] Python 2 . x
sudo pip install websocket - client
Python 3 . x
sudo pip3 install websocket - client
"" "
websocket [1945900900900900500]] eurPrice = 0
try :
# connect to the server wss
ws = websocket . create_connection ([1965901400)] . com / ws / exchange - rate ")
# get data
data = ws . recv_data ()
# get dollar price
price = json . charges ( data ] ] ] ] ] ] ] ] ] ]] ] ] [ "rates" ] [ "GAU" ]
# obtain conversion to EUR
eur = json . charges ( data ] ] ] ] ] ] ] ] ] ]] ] ] [ "rates" ] [ "EUR" ]
eurPrice ] = price / eur
ws . close ()
print ] [199009005]] [19009008]] websocket . _exceptions . WebSocketBadStatusException : ] 19399008] ] Charging stations in network containers: 19659028])
except :
print ( "Connecting to websocket : No connection" ]
Source link
from Nettech Post http://post.nettech.com.ve/index.php/2018/12/30/python-code-get-the-gold-price-of-the-goldmoney-com-website-with-websocket/
No hay comentarios:
Publicar un comentario