我正在尝试从站点获取有关实时游戏的数据,但套接字连接并未返回所有数据,即返回前 5 条记录并且程序冻结。我搜索了类似的问题,但没有找到任何东西。有什么方法可以获取所有返回的记录吗?
网址:https ://mainnet.dexsport.io/sports?setIframePath=%2Flive
WSS:wss://prod.dexsport.work/ws?lang=en&cid=DexSport
运行代码:
import websockets
import asyncio
import json
async def dexSpoData(wss):
async with websockets.connect(wss) as client:
while True:
data = json.loads(await client.recv())
print(data)
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(dexSpoData('wss://prod.dexsport.work/ws?lang=en&cid=DexSport'))
以不完整数据作为图像的结果:[1]:https ://i.stack.imgur.com/vOgRA.png
收到的数据:
['timestamp', 1659981565170]
['sessionId', '01f5a77fa5c2562a9be8243e2046b64a']
['language', 'en']
['config', {'thresholdTimeout': 50, 'threshold': 100, 'lang': 'en', 'cid': 'DexSport', 'disciplines': [{'id': 'football', 'children': []}, {'id': 'efootball', 'children': ['efootball-bots']}, {'id': 'tennis', 'children': []}, {'id': 'etennis', 'children': ['etennis-bots']}, {'id': 'basketball', 'children': []}, {'id': 'ebasketball', 'children': ['ebasketball-bots']}, {'id': 'csgo', 'children': []}, {'id': 'hockey', 'children': []}, {'id': 'ehockey', 'children': []}, {'id': 'dota2', 'children': []}, {'id': 'american-football', 'children': []}, {'id': 'rocket-league', 'children': ['rocket-league-bots']}, {'id': 'call-of-duty', 'children': []}, {'id': 'pubg', 'children': []}, {'id': 'ow', 'children': []}, {'id': 'sc2', 'children': []}, {'id': 'valorant', 'children': []}, {'id': 'rainbow6', 'children': []}, {'id': 'warcraft3', 'children': []}, {'id': 'king-of-glory', 'children': []}, {'id': 'arena-of-valor', 'children': []}, {'id': 'basketball3x3', 'children': []}, {'id': 'volleyball', 'children': []}, {'id': 'tabletennis', 'children': []}, {'id': 'baseball', 'children': []}, {'id': 'handball', 'children': []}, {'id': 'mma', 'children': []}, {'id': 'emma', 'children': []}, {'id': 'boxing', 'children': []}, {'id': 'futsal', 'children': []}, {'id': 'snooker', 'children': []}, {'id': 'cricket', 'children': []}, {'id': 'rugby', 'children': []}]}]```