赞
踩
远程服务端(客户端)代码:
pip install websocket-client==1.3.1
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- _AUTHOR_ = "许潇洒"
- _DATE_ = "2022/03/17 16:45"
-
-
-
- import websocket
- import json
- import time
-
- '模仿dory连接服务端发送字幕数据'
-
- class WS:
- def __init__(self, ws_url):
- self.ws_url = ws_url
-
- def on_open(self, ws):
- print('on_open: start......')
- while True:
- ws.send(
- json.dumps({'cnText': '我突然想', 'enText': 'I suddenly thought.', 'language': 'cn', 'resultType': '0',
- 'roomId': '123456', 'senderId': '521495', 'senderName': 'w',
- 'senderTime': 1636527647651}))
- print('send')
- time.sleep(2)
-
- def main(self):
- print(f'connecting {self.ws_url}')
- ws =
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。