標簽:imp rgb and style wss str png 驗證 span
websockect基础还有原理 省略
PS:這裏我說下aiowebsocket這個依賴庫,堪稱垃圾中的戰鬥機,在Mac(Linux沒測試過,但是Mac的內核是Linux,放到centOS我估計也會出這個問題)上一直報錯SSL證書錯誤,在windowes上handshakes.py一直找不到請求頭,不推薦使用這個庫
正確姿勢,適合WS/WSS:
、
import asyncio import websockets import json async def auth_system(websocket): # 第一次握手发送的驗證数据 message = ‘驗證数据‘ # 等待接收返回數據 await websocket.send(message) # 賦值接收的返回數據 response_str = await websocket.recv() print("返回數據",response_str) # 客戶端主邏輯 async def main_logic(): async with websockets.connect(‘wss:請求連接‘) as websocket: await auth_system(websocket) if __name__ == ‘__main__‘: asyncio.get_event_loop().run_until_complete(main_logic())
標簽:imp rgb and style wss str png 驗證 span
原文地址:https://www.cnblogs.com/wanghong1994/p/14919479.html