Diễn đàn xây dựng - Chợ xây dựng http://choxaydung.vn/forum/ |
|
Minecraft Server Help? http://choxaydung.vn/forum/viewtopic.php?f=37&t=79173 |
Bạn đang xem trang 1 / 1 trang |
Người gửi: | blalie [ Thứ 5 11/05/23 9:07 ] |
Tiêu đề bài viết: | Minecraft Server Help? |
I am using the official Minecraft server API, but I am having trouble getting the server status information to display correctly. Specifically, I am struggling to parse the JSON response from the API and extract the relevant data. Here is the code that I am using to make the API request: import requests import json serverurl = "https://api.mcsrvstat.us/2/<serverip>" response = requests.get(serverurl) jsondata = json.loads(response.text) When I try to access the data using json_data["players"]["online"], for example, I get a KeyError indicating that the "players" key does not exist. I would appreciate any suggestions or guidance on how to properly parse and access the data returned by the API. Thank you in advance for your help! |
Người gửi: | eire3333 [ Thứ 5 11/05/23 9:08 ] |
Tiêu đề bài viết: | Re: Minecraft Server Help? |
It looks like you're on the right track with using the Minecraft server status API. Since you're getting a KeyError, it's possible that the response you're receiving is not in the format you're expecting. You can try printing out the response and examining the structure of the JSON data to make sure you're accessing the correct keys. You may also want to check the API documentation to ensure that you're using the correct endpoint and parameters. Good luck! |
Bạn đang xem trang 1 / 1 trang | Thời gian được tính theo giờ UTC + 7 Giờ |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |