我有这个代码,但出于某种原因,获取市场上商品信息的请求对我不起作用。
response 有 status_code = 200 但 content = b'{"success":false}'
from base64 import b64encode
import requests
import rsa as rsa
# Creating a session
s = requests.session()
# Get the RSA key
response = s.get('https://steamcommunity.com/login/getrsakey/?username=USERNAME')
rsa_key = response.json()
# Create a public key
public_key = rsa.PublicKey(int(rsa_key['publickey_mod'], 16), int(rsa_key['publickey_exp'], 16))
# Encrypt password
password = 'PASSWORD'
password_encrypted = b64encode(rsa.encrypt(password.encode(), public_key)).decode()
# Log in
response = s.post('https://steamcommunity.com/login/dologin/',
data={'username': 'USERNAME',
'password': password_encrypted,
'twofactorcode': '',
'emailauth': '',
'loginfriendlyname': '',
'captchagid': '-1',
'captcha_text': '',
'emailsteamid': '',
'rsatimestamp': '',
'remember_login': False,
'donotcache': '',
'login': 'Sign in'})
# Obtaining price history
item_name = "Glove Case"
url = f"https://steamcommunity.com/market/pricehistory/?appid=730&market_hash_name={item_name}"
response_item = s.get(url)
if response_item.status_code == 200:
data = response_item.json()
for item in data:
print(f"Price for {item['timestamp']} - {item['price']} USD")
else:
print(f"Error {response_item.status_code}: {response_item.reason}")
我希望每天收到物品的价格。
我需要执行一个仅在登录时执行的查询:https://steamcommunity.com/market/pricehistory/?appid=730&market_hash_name=Glove%20Case
文档:https://github.com/Revadike/InternalSteamWebAPI/wiki/Get-Market-Price-History