Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import sys
  4. import os
  5. import urllib.request
  6. import json
  7. from urllib.parse import quote
  8.  
  9. URL='http://steamcommunity.com/inventory/'
  10. PRICES_URL='http://steamcommunity.com/market/priceoverview/?currency=3&appid='
  11. INV='76561197983160958'
  12. APPID='578080'
  13. LANG='2?l=english'
  14.  
  15. # DEfault 5000
  16. COUNT='5000'
  17.  
  18. items = { }
  19.  
  20. #URL zum Inventory
  21. inventory_url = urllib.request.urlopen(URL + '/' + INV + '/' + APPID + '/' + LANG + '/' + COUNT)
  22. inventory_url_data = inventory_url.read()
  23. encoding = inventory_url.info().get_content_charset('utf-8')
  24. inventory_json = json.loads(inventory_url_data.decode(encoding))
  25.  
  26. total_inventory_count = inventory_json['total_inventory_count']
  27.  
  28. print ( "Du hast %s Items am Start" % (total_inventory_count))
  29.  
  30. #len (inventory_json["descriptions"])
  31.  
  32. i = 0
  33. while i < (len (inventory_json["descriptions"])):
  34. count = [ ]
  35. items.update(inventory_json["descriptions"][i])
  36. itemname = items["market_hash_name"]
  37. print ( itemname )
  38. encoded_itemname = quote(itemname)
  39. try:
  40. prices_url = urllib.request.urlopen(PRICES_URL + APPID + '&market_hash_name=' + encoded_itemname)
  41. prices_url_data = prices_url.read()
  42. encoding = prices_url.info().get_content_charset('utf-8')
  43. prices_json = json.loads(prices_url_data.decode(encoding))
  44. # print ( prices_json["median_price"] )
  45. except urllib.error.HTTPError:
  46. pass
  47.  
  48.  
  49. classid = items["classid"]
  50. #print ( classid )
  51.  
  52. a = 0
  53. while a < (len(inventory_json["assets"])):
  54. if (inventory_json["assets"][a]["classid"] == classid):
  55. count.append(classid)
  56. #print ( classid )
  57. a += 1
  58. else:
  59. a += 1
  60. try:
  61. print ( prices_json["median_price"] )
  62. del prices_json
  63. except NameError:
  64. pass
  65.  
  66. print (len(count))
  67. i += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement