#体赛反爬破解
import json, time import websocket import ssl #https://www.tisai.com/ class OTC: url = 'wss://push.tisai.com:37272/' #定义好请求的数据 data_info = {"type":"football","is_pc":"1"} def get_web_socket(self): while 1: try: ws = websocket.create_connection(self.url,sslopt={"cert_reqs":ssl.CERT_NONE}) # ws.run_forever(sslopt={'cert_reqs': ssl.CERT_NONE}) # 发送消息 ws.send(json.dumps(self.data_info)) # 接收消息 data = ws.recv() result = json.loads(data) print(result) print("-" * 200) # 数据监测间隔 time.sleep(1) except Exception as e: print('retry to connect...',e) otc = OTC() otc.get_web_socket()