python 2.7 websocket抓取数据问题 求助

下面是截图图片说明

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 ###")

def on_open(ws):
    def run(*args):
        for i in range(3):
            time.sleep(1)
            ws.send("Hello %d" % i)
            time.sleep(1)
            ws.close()
            print("thread terminating...")
            thread.start_new_thread(run, ())

if __name__ == "__main__":
    websocket.enableTrace(True)
    ws = websocket.WebSocketApp("wss://premws-pt12.365lpodds.com/zap/?uid=66410782450749107",

        # wss://mpshudws.365lpodds.com/zap/?uid=42846771150121565
        # wss://premws-pt13.365lpodds.com/zap/
                                on_message=on_message,
                                on_error=on_error,
                                on_close=on_close)
    ws.on_open = on_open
    ws.run_forever()

报错信息————————
--- request header ---
GET /zap/?uid=66410782450749107 HTTP/1.1

Upgrade: websocket

Connection: Upgrade

Host: premws-pt12.365lpodds.com

Origin: http://premws-pt12.365lpodds.com

Sec-WebSocket-Key: 0qd7TsIQEP9BbRx/JXzFQw==

Sec-WebSocket-Version: 13


--- response header ---
HTTP/1.1 400 Bad Request
server: Cowboy
date: Thu, 20 Dec 2018 03:11:30 GMT

content-length: 0

Handshake status 400 Bad Request

closed

报错信息————————

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐