Skip to content

Instantly share code, notes, and snippets.

@icehongssii
Last active May 21, 2018 04:24
Show Gist options
  • Save icehongssii/5209aa0637318cfb60522c8fdda7b46b to your computer and use it in GitHub Desktop.
Save icehongssii/5209aa0637318cfb60522c8fdda7b46b to your computer and use it in GitHub Desktop.
Return data from wss.bithumb.com
import websocket #pip install websocket-client
import thread
import time
import json
def on_message(ws, message):
print(message)
print
print
def on_error(ws, error):
print(error)
def on_close(ws):
print("### closed ###")
def on_open(ws):
print("ONOPEN")
def run(*args):
ws.send(json.dumps({currency: "ETH", tickDuration: "24H"}))
while True:
time.sleep(1)
ws.close()
print("thread terminating...")
thread.start_new_thread(run, ())
if __name__ == "__main__":
websocket.enableTrace(True)
ws = websocket.WebSocketApp("wss://wss.bithumb.com/public",
on_message = on_message,
on_error = on_error,
on_close = on_close)
ws.on_open = on_open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment