Created
July 20, 2018 03:30
-
-
Save icehongssii/1c8ec1755dfee88c2789714ee9a37738 to your computer and use it in GitHub Desktop.
Getting marketdata without AUTH
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import websocket | |
import json | |
def on_msg(ws,msg): | |
print(msg) | |
def on_cls(ws): | |
print("close") | |
def on_open(ws): | |
print("open") | |
ws.send(json.dumps({'e': "subscribe", 'rooms': ["tickers", "pair-ETH-USD"]})) | |
def on_er(ws,er): | |
print(str(er)) | |
headers={ | |
'User-Agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)', | |
'Accept-Language': 'en-us', | |
'Keep-Alive': '300', | |
'Connection': 'keep-alive', | |
'Cache-Control': 'max-age=0', 'Origin':'https://cex.io'} | |
url = "wss://ws.cex.io/ws" | |
websocket.enableTrace(False) | |
ws = websocket.WebSocketApp(url, header=headers,cookie="_gat=1; _ga=GA1.2.844654147.1407933481", on_open=on_open, on_message=on_msg, on_close=on_cls, on_error = on_er) | |
ws.run_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment