Steam_Calculator
March 10, 2018
功能与steamdb类似,可以计算出你的steam账号上游戏的总价(不包括dlc)
遇到某些锁区的游戏会出bug,比如 csgo, payday2,请自行特判
需要注意的是steamid是17位纯数字,与账号id不同,具体自行百度
key请自行去steam社区申请:http://steamcommunity.com/dev
import requests import json key = '483C48DD8DDBE160938EF2F06B149218' #将其换成你自己申请的key steam_id = '76561198285460374' #换成自己的steamid GetOwnedGames_API = 'http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/?key=' + key + '&steamid=' + steam_id + '&format=json' def query_price(app): appdetails_API = 'http://store.steampowered.com/api/appdetails/?appids=' + str(app) + '&cc=cn' detail_req = requests.get(appdetails_API).text detail_json = json.loads(detail_req) if app == 218620: #payday2,原因也许是不单独售卖? price = 68 return price if app == 545100: #payday2的dlc,不知道为什么会出现在商店界面 price = 11 return price if app == 730: #csgo price = 48 return price if detail_json[str(app)]['success'] == 0: #有些游戏找不到,原因未知 price = 0 return price if detail_json[str(app)]['data']['is_free']: #免费游戏 price = 0 return price else: price = detail_json[str(app)]['data']['price_overview']['initial'] / 100 #默认为分 return price req = requests.get(GetOwnedGames_API).text games_json = json.loads(req) games = games_json['response']['games'] #print (query_price(218620)) price_total = 0 for game in games: appid = game['appid'] #print (appid) price = query_price(appid) price_total = price_total + price print (price_total)