如何检索蒸汽市场价格历史? [英] How to retrieve steam market price history?

查看:46
本文介绍了如何检索蒸汽市场价格历史?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取 Steam 市场上物品的价格历史记录.我找到了一个链接,可以返回特定商品的价格历史记录(几乎每个关于从本网站的市场获取价格历史记录的问题中都会提到).

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

当我登录 Steam 时,它在浏览器中运行良好,但是当我尝试在 python 中执行相同的操作时,它返回一个空列表(当我尝试在浏览器中执行但未执行时,会发生同样的事情)正在登录 Steam).这是我的python代码(使用请求库):

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)

那么,问题是:有没有什么方法可以模拟在使用 Python(或其他语言)发出请求的同时登录 Steam?

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

推荐答案

您需要将 CookiesteamLogin 设置为您的会话 ID.您可以在浏览器上执行登录并获取此值.

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);

我在这里使用了一个随机的 steamLogin 值,将其更改为您的会话 ID.

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

您也可以尝试通过 python 执行登录,但您可能需要关闭 Steam 防护以使事情更简单.我会演示自动执行登录,但我不希望禁用我的 Steam 防护并获得 15 天的交易限制.

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.

这篇关于如何检索蒸汽市场价格历史?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆