Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import urllib.request, json
price_c = {}
price_u = {}
price_r = {}
N_check=0
with urllib.request.urlopen("https://steamcommunity.com/market/search/render/?search_descriptions=0&category_583950_Rarity%5B%5D=tag_Rarity_Common&sort_dir=desc&appid=583950&norender=1&count=500") as url:
    data_c = json.loads(url.read().decode())
for entry in data_c['results']:
    price_c[entry['name']] = entry['sell_price']/100
with urllib.request.urlopen("https://steamcommunity.com/market/search/render/?search_descriptions=0&category_583950_Rarity%5B%5D=tag_Rarity_Uncommon&sort_dir=desc&appid=583950&norender=1&count=500") as url:
    data_u = json.loads(url.read().decode())
for entry in data_u['results']:
    price_u[entry['name']] = entry['sell_price']/100

with urllib.request.urlopen("https://steamcommunity.com/market/search/render/?search_descriptions=0&category_583950_Rarity%5B%5D=tag_Rarity_Rare&sort_dir=desc&appid=583950&norender=1&count=500") as url:
    data_r = json.loads(url.read().decode())

for entry in data_r['results']:
    N_check=N_check+1
    price_r[entry['name']] = entry['sell_price']/100
heroes = ["Zeus", "Enchantress", "Magnus", "Bounty Hunter", "Lion", "Bloodseeker", "Ogre Magi", "Necrophos", "Crystal Maiden", "Dark Seer", "Beastmaster", "Mazzie", "Bristleback", "Sven", "Lycan" , "Treant Protector", "Skywrath Mage", "Venomancer", "Phantom Assassin", "Ursa", "Viper", "Outworld Devourer", "Luna", "Timbersaw", "Tidehunter", "Rix", "Winter Wyvern", "Sniper", "Prellex", "Sorla Khan", "Legion Commander"]
starter = ["Sven", "Lycan", "Ursa", "Necrophos", "Skywrath Mage", "Ogre Magi"]
avg_u = 0
avg_c=0
avg_r=0
N_c=78
N_u=82
N_r=77
print(N_check)
for cost in price_c:
  avg_c += price_c[cost]/N_c
print(avg_c)

for cost in price_u:
  avg_u += price_u[cost]/N_u
print(avg_u)

for cost in price_r:
  avg_r += price_r[cost]/N_r
print(avg_r)

value=8*avg_c+3*avg_u+avg_r
print(value)

Python 3.6.1 (default, Dec 2015, 13:05:11) [GCC 4.8.2] on linux