相关疑难解决方法(0)

如何在 websocket python 中发送“标头”

我怎样才能做到这一点

这是我的代码


import  websockets


async def test():
    async with websockets.connect('ws://iqoption.com') as websocket:
        response = await websocket.recv()
        print(response)
# Client async code
Run Code Online (Sandbox Code Playgroud)

提示是,我可以发送此标头以在服务器中进行身份验证吗

标头

    'Host':'iqoption.com',
    'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0',
    'Accept' : '*/*',
'Accept-Encoding': 'gzip, deflate',
'Sec-WebSocket-Version' : '13',
'Origin' : 'https://iqoption.com',
    'Sec-WebSocket-Key': 'iExBWv1j6sC1uee2qD+QPQ==',
'Connection' : 'keep-alive, Upgrade',
'Upgrade': 'websocket'}
Run Code Online (Sandbox Code Playgroud)

我可以用其他代码做到这一点,但消息仍然用 tls 加密

proxies = {"http": "http://127.0.0.1:8080", "https": "http://127.0.0.1:8080"}
urllib3.disable_warnings()

r = requests.get('https://iqoption.com/echo/websocket', stream=True,headers = Headers, proxies=proxies, verify=False)
#r = requests.get('https://iqoption.com/echo/websocket', stream=True,headers = Headers)
s = …
Run Code Online (Sandbox Code Playgroud)

python sockets websocket python-3.x

5
推荐指数
1
解决办法
3933
查看次数

标签 统计

python ×1

python-3.x ×1

sockets ×1

websocket ×1