39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
import requests
|
|
|
|
|
|
class MpGameList:
|
|
def __init__(self):
|
|
self.mp_games_url = "https://mp.kingsome.cn/api/open/games/list"
|
|
|
|
def get_gameid(self):
|
|
r = requests.get(self.mp_games_url)
|
|
all = []
|
|
if r.status_code == requests.codes.ok:
|
|
try:
|
|
data = r.json().get("gameList")
|
|
except Exception:
|
|
print(f"get data failed!")
|
|
try:
|
|
for line in data: # {"game":"一起织娃娃","game_id":8002,"game_name":"knitting","platform":"weixin","platform_id":6001,"platform_name":"微信"}
|
|
if line.get("platform") == "test":
|
|
continue
|
|
else:
|
|
temp = {}
|
|
temp['name_cn'] = line.get("game", "")
|
|
temp['game_id'] = line.get("game_id", 0)
|
|
temp['platform_name'] = line.get("platform_name", "")
|
|
temp['platform_id'] = line.get("platform_id", 0)
|
|
all.append(temp)
|
|
except Exception:
|
|
print(f"split data with{r.json()} failed")
|
|
return all
|
|
else:
|
|
return None
|
|
|
|
|
|
if __name__ == "__main__":
|
|
mm = MpGameList()
|
|
data = mm.get_gameid()
|
|
print(data)
|