Этот код должен выводить предметы с инвентаря steam и их стоимость
т.к. я не разбираюсь в python коде мне надо помощь в исправление ошибок в коде
import time
import requests
wear_list = ['Factory New', 'Minimal Wear', 'Field-Tested', 'Well-Worn', 'Battle-Scarred']
INVENTORY_URL = 'http://steamcommunity.com/profiles/{}/inventory/js...'
MARKET_URL = 'steamcommunity.com/market/priceoverview'
def get_inventory(steamid):
r = requests.get(INVENTORY_URL.format(steamid))
return r.json()['rgDescriptions']
def extract_information(descriptions):
for _, item in descriptions.items():
tags = {i['category']: i for i in item['tags']}
name = tags['market_name']
yield {
'name': name[name.find('|')+1:name.find('(')].strip(),
'market_name': name,
'market_hash_name': item['market_hash_name'],
'wear': tags['Exterior']['name'],
'gun': tags['Weapon']['name'],
'stattrak': 'StatTrak' in tags['Quality']['name'],
'marketable': item['marketable'],
}
def get_prices(items):
for item in items:
if not item['marketable']:
continue
if item['wear'] not in wear_list:
continue
r = requests.get(
MARKET_URL,
params={
'appid': '730',
'currency': '2',
'market_hash_name': item['market_hash_name']
}
)
json_data = r.json()
try:
price = json_data['lowest_price']
except KeyError:
price = json_data['median_price']
item['price'] = price[-4:]
time.sleep(5)
yield item
if __name__ == '__main__':
inventory = get_inventory('76561198996231585')
item_information = extract_information(inventory)
items = get_prices(item_information)
for item in items:
print('{name}: {price}'.format(**item))
Ошибка
Traceback (most recent call last):
File "steam_price_item.py", line 59, in
for item in items:
File "steam_price_item.py", line 31, in get_prices
for item in items:
File "steam_price_item.py", line 19, in extract_information
market_name = tags['name'],
KeyError: 'name'