Skip to content

Instantly share code, notes, and snippets.

@gmemstr
Created October 2, 2016 20:31
Show Gist options
  • Save gmemstr/3d514891d78a9484fdc310737fc32e07 to your computer and use it in GitHub Desktop.
Save gmemstr/3d514891d78a9484fdc310737fc32e07 to your computer and use it in GitHub Desktop.
import requests
import xml.etree.ElementTree as ET
import json
bots_total = 89
bots_price = 0
bots_individual = ""
i = 1
while i < bots_total:
r = requests.get("https://steamcommunity.com/id/tf2scrap" + str(i) + "?xml=1")
root = ET.fromstring(r.text)
if root[0].text == "The specified profile could not be found.":
print("tf2scrap" + str(i) + " could not be found.")
else:
print("tf2scrap" + str(i) + " found.")
bots_individual = bots_individual + root[0].text + ","
i = i + 1
q = requests.get("https://backpack.tf/api/IGetUsers/v3/?steamids=" + bots_individual)
# For debugging
# print(q.json()['response']['players']['76561198068475408']['backpack_value'])
for bot in q.json()['response']['players']:
try:
value = q.json()['response']['players'][bot]['backpack_value']['440']
except:
value = 0
bots_price = bots_price + value
print(bots_price)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment