Last active
January 24, 2023 21:46
-
-
Save marccane/163648afb3431668bb80c87947d8122c to your computer and use it in GitHub Desktop.
steamMarketHistoryFilterByGameID.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python | |
#quick 'n dirty script to filter market history by game id (csgo in this case) | |
#to get the data you go to https://steamcommunity.com/market/, f12, change page to request next batch of 10 results | |
#goto network mode, edit and resend request, put the starting index to 0 and count to ~300 | |
#if you request too much the server throws an error. Finally you copy the contents of the response message which is a json | |
#and name it 1.json. If you have more than 300 results which is likely, you'll have to make multiple queries, changing the index appropiately | |
#and naming the next files 2.json... You also have to modify the code if you have more than 2 files | |
#Only the name of the item is shown, as the price and other info seems to only be encoded in the html which is discarded right now | |
import json | |
f=open("1.json") | |
data=json.load(f) | |
f2=open("2.json") | |
data2=json.load(f2) | |
def printkeys(m, d, name): | |
if d <= 2 and isinstance(m, dict): | |
print(" "*d,name,":",m.keys()) | |
for key in m.keys(): | |
printkeys(m[key],d+1,key) | |
printkeys(data, 0, "data") | |
printkeys(data2, 0, "data2") | |
print("Total csgo transactions:",len(data["assets"]["730"]["2"]) + len(data2["assets"]["730"]["2"])) | |
print() | |
csgoTransactions=[] | |
for key in data["assets"]["730"]["2"]: | |
csgoTransactions+=[data["assets"]["730"]["2"][key]] | |
for key in data2["assets"]["730"]["2"]: | |
csgoTransactions+=[data2["assets"]["730"]["2"][key]] | |
#m1=map(lambda x: (x["name"],x["status"]), data["assets"]["730"]["2"].values()) | |
m1=map(lambda x: (x["name"], x["status"]), csgoTransactions) | |
print("\n".join(map(lambda x: str(x), m1))) | |
f.close() | |
f2.close() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment