我有下面的代码,它发出一个API调用,返回关于市场上每个列表的信息.出于隐私考虑,我已经删除了客户ID和客户机密.
"""
import base64
import requests
clientId = "fakeId"
clientSecret = "fakeSecret"
clientData = f"{clientId}:{clientSecret}"
encodedData = str(base64.b64encode(clientData.encode("utf-8")), "utf-8")
authorizationHeaderString = f"Basic {encodedData}"
import requests
r = requests.get("https://api.skinport.com/v1/items", params={
"app_id": 730,
"currency": "EUR",
"tradable": 0
}).json()
print(r)
"""
以下是输出中的一个示例:
"""
{'market_hash_name': 'USP-S | Whiteout (Factory New)', 'currency': 'EUR', 'suggested_price': 153.1, 'item_page': 'https://skinport.com/item/usp-s-whiteout-factory-new', 'market_page': 'https://skinport.com/market?item=Whiteout&cat=Pistol&type=USP-S', 'min_price': 171.03, 'max_price': 232.16, 'mean_price': 197.13, 'median_price': 194.25, 'quantity': 7, 'created_at': 1633294586, 'updated_at': 1693686845}, {'market_hash_name': 'USP-S | Whiteout (Field-Tested)', 'currency': 'EUR', 'suggested_price': 22.18, 'item_page': 'https://skinport.com/item/usp-s-whiteout-field-tested', 'market_page': 'https://skinport.com/market?item=Whiteout&cat=Pistol&type=USP-S', 'min_price': 19.25, 'max_price': 175, 'mean_price': 41.53, 'median_price': 36.55, 'quantity': 61, 'created_at': 1632899292, 'updated_at': 1693686845}, {'market_hash_name': 'USP-S | Whiteout (Minimal Wear)', 'currency': 'EUR', 'suggested_price': 32.96, 'item_page': 'https://skinport.com/item/usp-s-whiteout-minimal-wear', 'market_page': 'https://skinport.com/market?item=Whiteout&cat=Pistol&type=USP-S', 'min_price': 39.64, 'max_price': 185, 'mean_price': 77.81, 'median_price': 69.99, 'quantity': 61, 'created_at': 1632921139, 'updated_at': 1693686845}, {'market_hash_name': 'USP-S | Whiteout (Well-Worn)', 'currency': 'EUR', 'suggested_price': 17.62, 'item_page': 'https://skinport.com/item/usp-s-whiteout-well-worn', 'market_page': 'https://skinport.com/market?item=Whiteout&cat=Pistol&type=USP-S', 'min_price': 19.79, 'max_price': 32, 'mean_price': 25.9, 'median_price': 25.9, 'quantity': 2, 'created_at': 1632976633, 'updated_at': 1693686845}, {'market_hash_name': 'Valeria Phoenix Pin', 'currency': 'EUR', 'suggested_price': 51.74, 'item_page': 'https://skinport.com/item/valeria-phoenix-pin', 'market_page': 'https://skinport.com/market?item=Valeria%20Phoenix%20Pin&cat=Collectible', 'min_price': 53.95, 'max_price': 80, 'mean_price': 63.66, 'median_price': 59.99, 'quantity': 14, 'created_at': 1535988295, 'updated_at': 1693686845},
"""
我对JSON格式化比较不熟悉,所以我的问题是,筛选返回的数据的最佳方式是什么,这样我就可以存储关于满足特定条件的项的信息.例如,程序返回成千上万行关于列表的信息,但我只关心某个market_hash_name或某个min_Price的列表,或者两者兼而有之.
我确信有一种方法可以通过编辑API调用来实现这一点,但我更喜欢通过简单地格式化返回的JSON来实现这一点.
谢谢你的帮助!