import requests import time # API请求链接 room_id = "17079648294690" timestamp = int(time.time() * 1000) print(timestamp) api_url = f"https://live-api.immomo.com/open/m/room/profile?roomid={room_id}&momoid=&src=m50011&web_uid=11126216061Xazx3TgC&_= {timestamp}" # 发起API请求 response = requests.get(api_url) data = response.json() # 提取信息 title = data["data"]["title"] #anchor_info = data["data"]["anchor_info"] avatar_url = data["data"]["cover"] cover_url = data["data"]["cover"] m3u8 = data["data"]["url"] m3u81 = data["data"]["revertStream"] online_users = data["data"]["online"] nickname = data["data"]["stars"][0]["nickname"] momoid = data["data"]["momoid"] # 获取ws_token及其他可显示信息 ws_token = data["data"].get("ws_token", "") socketUrl = data["data"]["socketUrl"] #live_url = data["data"]["push_stream"] # 输出信息 print("直播间信息:") print(f"标题:{title}") print("主播:", nickname) #print("主播信息:", anchor_info) print(f"主播头像链接:{avatar_url}") #print(f"直播间封面链接:{cover_url}") print(f"在线人数:{online_users}") print("媒体流:", m3u8) print("媒体流1:", m3u81) print("wss:", socketUrl) print(f"ws_token:{ws_token}") print(f"momoid:{momoid}")