依赖:https://github.com/lexiforest/curl_cffi?tab=readme-ov-file
该工具能够过ja3,并且支持websocket
如果已经安装过的,一定要注意更新,老版本不支持websocket,pip install curl_cffi --upgrade
from curl_cffi.requests import Session, WebSocket
def on_message(ws: WebSocket, message):
print(message)
with Session() as s:
ws = s.ws_connect(
"wss://api.gemini.com/v1/marketdata/BTCUSD",
on_message=on_message,
)
ws.run_forever()