Python - 模拟Web Socket 请求
Max.Bai
2017-04
有可能你找的是这个 套接字Socket
Socket Client
需要用到socketio-client, logging
1. 安装SockeIO-Client
pip install socketio-client-2
2. 创建连接发送数据
from socketIO_client import SocketIO
hosts = 'http://websocke.server.com'
port = 3000
# 收到message消息处理过程
def on_message(*args):
# print "recv:", args
# print "geted:", type(args[0])
if type(args[0]) is types.DictType:
rp = args[0]
print "recv:", rp
sk = SocketIO(hosts,port=port)
sk = SocketIO(hosts,port=port,params={'token': 'ksdjfkjdf'}) #create connection with params
# add lisenter for message response
sk.on('message', on_message)
data = {
"sn": 0,
"ver": 2}
# send dat

本文介绍了如何使用Python的SocketIO客户端库来模拟Web Socket请求,包括安装SocketIO-Client、建立连接、发送数据以及进行调试。同时提供了一个简单的WebSocket服务器用于调试。
最低0.47元/天 解锁文章

4495

被折叠的 条评论
为什么被折叠?



