How to retrieve steam market price history?

旧时模样 提交于 2019-12-30 11:56:48

问题


I'm trying to get price history for items on steam market. I found a link that returns price history for a specific item (which is mentioned in almost every question about getting price history from market at this site).

http://steamcommunity.com/market/pricehistory/?country=PT&currency=3&appid=730&market_hash_name=Falchion%20Case

It works fine in browser while I'm logged-in in Steam, but when I try to do the same thing in python, it returns an empty list (the same thing happens when I try to do it in browser while not being logged-in in Steam). This is my python code (uses requests lib):

import requests

params = {'country': 'RU', 'currency': 5, 'appid': 730, 'market_hash_name': 'Falchion%20Case'}
data = requests.get('http://steamcommunity.com/market/pricehistory', params=params)
print(data.text)

So, the question is: is there any way to emulate being logged-in in Steam while making requests in python (or some other language)?


回答1:


You need to set the Cookie key steamLogin to your session id. You can perform login on your browser and get this value.

cookie = {'steamLogin': '76561198058933558%7C%7C2553658936E891AAD'}    
data = requests.get('http://steamcommunity.com/market/pricehistory/?country=PT&currency=3&appid=730&market_hash_name=Falchion%20Case', cookies=cookie);

I have used a random steamLogin value here, change it to your session id.

You can try performing login from through python as well, but you might want to turn off steam guard for making things simpler. I would have demonstrated performing login automatically, but I don't wish to disable my steam guard and get a 15 day trading restriction.



来源:https://stackoverflow.com/questions/31961868/how-to-retrieve-steam-market-price-history

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!