如何获取游戏的名称、描述、价格,但不使用“python-steam-api”?
我这样做了,但它使用的是
python-steam-api
from decouple import config
KEY = config("STEAM_API_KEY")
steam = Steam(KEY)
game = steam.apps.get_app_details(271590)
print(game)
Valve 文档仅指定获取有关用户信息的可能性,并且只能通过它们获取有关游戏的任何信息
我正在查看的文档 - https://developer.valvesoftware.com/wiki/Steam_Web_API
您可以使用steam店面API。它与 steam Web API 是分开的。它是非官方的,由 Steam 商店本身使用。
import requests
def get_game_details(app_id):
url = f"https://store.steampowered.com/api/appdetails?appids={app_id}"
response = requests.get(url)
data = response.json()
if data[str(app_id)]['success']:
game_data = data[str(app_id)]['data']
name = game_data['name']
description = game_data['short_description']
if 'price_overview' in game_data:
price = game_data['price_overview']['final_formatted']
else:
price = 'Free' if game_data['is_free'] else 'price not available'
return {
'name': name,
'description': description,
'price': price
}
else:
return 'details not found'
app_id = 111111 # replace it with our game app id
game_details = get_game_details(app_id)
print(game_details)