美文网首页
python获取币安websocket接口数据

python获取币安websocket接口数据

作者: 骄傲的葡萄干 | 来源:发表于2018-06-28 13:09 被阅读411次

用来获取所有币的价格,使用的库websocket-client

import websocket
try:
    import thread
except ImportError:
    import _thread as thread
import time

def on_message(ws, message):
    print(message)

def on_error(ws, error):
    print(error)

def on_close(ws):
    print("### closed ###")

websocket.enableTrace(True)
ws = websocket.WebSocketApp("wss://stream.binance.com:9443/ws/!ticker@arr",
                          on_message = on_message,
                          on_error = on_error,
                          on_close = on_close)
ws.run_forever(sslopt={"check_hostname": False})

相关文章

网友评论

      本文标题:python获取币安websocket接口数据

      本文链接:https://www.haomeiwen.com/subject/ylsgyftx.html