How to get dynamic website url?

I'm trying to get data from the websocket of this page https://upbit.com/exchange?code=CRIX.UPBIT.KRW-BTC , but it looks like its website URL is dynamic and cannot be reused a second time, when I connect to it, it no longer sends me data, only the first connection is valid.

enter image description here

I have currently found a function in this JS file https://cdn.upbit.com/vender-bundle-03c1ef05e3ad23870adb.js ,

var a = this, c = o.addPath(t, "/websocket"); c = "https" === c.slice(0, 5) ? "wss" + c.slice(5) : "ws" + c.slice(4), this.url = c, this.ws = new u(this.url, [], n) 

There are thousands of functions with the same name n() , so I don't know what ideas? Thanks!

-one
javascript websocket
source share
1 answer

In this case, you do not need a dynamic URL. You can simply select one and use it as described in the answer below.

fooobar.com/questions/849127 / ...

 const WebSocket = require("ws") const ws = new WebSocket("wss://example.com/sockjs/299/enavklnl/websocket",null,{ headers: { "Cookie":"<cookie data noted earlier>", "User-Agent": "<Your browser agent>" }, origin: "https://example.com", }) const opening_message = '["[{\\"ticket\\":\\"ram macbook\\"},{\\"type\\":\\"recentCrix\\",\\"codes\\":[\\"CRIX.UPBIT.KRW-BTC\\",\\"CRIX.BITFINEX.USD-BTC\\",\\"CRIX.BITFLYER.JPY-BTC\\",\\"CRIX.OKCOIN.CNY-BTC\\",\\"CRIX.KRAKEN.EUR-BTC\\",\\"CRIX.UPBIT.KRW-DASH\\",\\"CRIX.UPBIT.KRW-ETH\\",\\"CRIX.UPBIT.KRW-NEO\\",\\"CRIX.UPBIT.KRW-BCC\\",\\"CRIX.UPBIT.KRW-MTL\\",\\"CRIX.UPBIT.KRW-LTC\\",\\"CRIX.UPBIT.KRW-STRAT\\",\\"CRIX.UPBIT.KRW-XRP\\",\\"CRIX.UPBIT.KRW-ETC\\",\\"CRIX.UPBIT.KRW-OMG\\",\\"CRIX.UPBIT.KRW-SNT\\",\\"CRIX.UPBIT.KRW-WAVES\\",\\"CRIX.UPBIT.KRW-PIVX\\",\\"CRIX.UPBIT.KRW-XEM\\",\\"CRIX.UPBIT.KRW-ZEC\\",\\"CRIX.UPBIT.KRW-XMR\\",\\"CRIX.UPBIT.KRW-QTUM\\",\\"CRIX.UPBIT.KRW-LSK\\",\\"CRIX.UPBIT.KRW-STEEM\\",\\"CRIX.UPBIT.KRW-XLM\\",\\"CRIX.UPBIT.KRW-ARDR\\",\\"CRIX.UPBIT.KRW-KMD\\",\\"CRIX.UPBIT.KRW-ARK\\",\\"CRIX.UPBIT.KRW-STORJ\\",\\"CRIX.UPBIT.KRW-GRS\\",\\"CRIX.UPBIT.KRW-VTC\\",\\"CRIX.UPBIT.KRW-REP\\",\\"CRIX.UPBIT.KRW-EMC2\\",\\"CRIX.UPBIT.KRW-ADA\\",\\"CRIX.UPBIT.KRW-SBD\\",\\"CRIX.UPBIT.KRW-TIX\\",\\"CRIX.UPBIT.KRW-POWR\\",\\"CRIX.UPBIT.KRW-MER\\",\\"CRIX.UPBIT.KRW-BTG\\",\\"CRIX.COINMARKETCAP.KRW-USDT\\"]},{\\"type\\":\\"crixTrade\\",\\"codes\\":[\\"CRIX.UPBIT.KRW-BTC\\"]},{\\"type\\":\\"crixOrderbook\\",\\"codes\\":[\\"CRIX.UPBIT.KRW-BTC\\"]}]"]' ws.on('open', function open() { console.log("opened"); }); ws.on('message', function incoming(data) { if (data == "o" || data == "h") { console.log("sending opening message") ws.send(opening_message) } else { console.log("Received", data) } }); 
+1
source share

All Articles