[Python] Python Websocket 403 handshake when I try to connect

Discussão em 'Python' iniciado por Stack, Março 20, 2025.

  1. Stack

    Stack Membro Participativo

    I'm new to websockets and am trying to play around with it. I'm trying to extract the messages on the two websites https://www.csgoroll.com/en/withdraw/csgo/p2p and https://csgoexo.com/, through chrome network tab i've identified the websocket as wss://api.csgoroll.com/graphql and wss://csgoexo.com/socket.io/?EIO=3&transport=websocket respectively but on both times when I try to connect I get Handshake status 403 Forbidden, and I don't know if i'm missing something or there isn't a way to connect. Here is my code:

    import websocket
    import _thread
    import time
    import rel

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

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

    def on_close(ws, close_status_code, close_msg):
    print("### closed ###")

    def on_open(ws):
    print("Opened connection")

    if __name__ == "__main__":
    websocket.enableTrace(True)
    ws = websocket.WebSocketApp("wss://csgoexo.com/socket.io/?EIO=3&transport=websocket",
    on_open=on_open,
    on_message=on_message,
    on_error=on_error,
    on_close=on_close)

    ws.run_forever(dispatcher=rel) # Set dispatcher to automatic reconnection
    rel.signal(2, rel.abort) # Keyboard Interrupt
    rel.dispatch()

    Continue reading...

Compartilhe esta Página