Advertisement
Guest User

Untitled

a guest
Dec 14th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.39 KB | None | 0 0
  1. from lxml import html
  2. import requests
  3. from openpyxl import load_workbook
  4. import json
  5. import unicodedata
  6. import datetime
  7.  
  8. wb = load_workbook(filename='Templates/gameCrate.xlsx')
  9.  
  10. apiKey = ''
  11. appId = ''    
  12.  
  13. price_cells = []
  14. product_names = []
  15. product_cells = []
  16. updated_prices = []
  17.  
  18.  
  19. for i in range(1,20):
  20.     product_cells.append("A"+str(i))
  21.     price_cells.append("D"+str(i))
  22. #print price_cells
  23.  
  24. for i in product_cells:
  25.     ws = wb.active
  26.     cell_string = ws[i].value
  27.     fixed_string = unicodedata.normalize('NFKD', cell_string).encode('ascii','ignore')
  28.     product_names.append(fixed_string)
  29. #print product_names
  30.  
  31. for item in product_names:
  32.     #print item
  33.     apiString = "http://api.steamapis.com/market/item/" + appId + "/" + item + "?api_key=" + apiKey
  34.     response = requests.get(apiString)
  35.     #mytext = response.text
  36.     parsed_json = json.loads(response.text)
  37.     #print parsed_json
  38.     print item, ":", parsed_json['histogram']['lowest_sell_order']
  39.     updated_prices.append(parsed_json['histogram']['lowest_sell_order'])
  40.  
  41. mynum = 0
  42. for i in updated_prices:
  43.     ws = wb.active
  44.     current_index = mynum
  45.     print "index:", str(current_index), "item:", i
  46.     ws[price_cells[current_index]] = i
  47.     mynum += 1
  48.  
  49.  
  50. time_stamp = datetime.datetime.now().strftime("%I%M%p-%B-%d-%Y")
  51. save_file = "Spreadsheets/PUBG_GAMECOM_updated_at_" + str(time_stamp) + ".xlsx"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement