main.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import json
  2. import requests
  3. import xlsxwriter
  4. import argparse
  5. markets = ['jita', 'perimeter', 'universe', 'amarr', "dodixie", "hek", "rens"]
  6. parser = argparse.ArgumentParser(prog="EVEGetPrice")
  7. parser.add_argument('-m', '--market', dest='market', default='jita', help="Market name")
  8. parser.add_argument('-n', '--name', dest='name', default='Example', help="Name File")
  9. args = parser.parse_args()
  10. headers = {
  11. 'User-Agent': 'A friend asked to take this information',
  12. 'From': 'alex.sidorof@ya.ru'
  13. }
  14. def get_type_ids():
  15. print("Запрос всех id у https://esi.evetech.net/latest/markets/prices/")
  16. return [{"type_id": x['type_id']} for x in requests.get("https://esi.evetech.net/latest/markets/prices/",
  17. headers=headers).json()]
  18. def get_json(market_name):
  19. print("Пошли брать данные")
  20. return requests.post(F"https://evepraisal.com/appraisal/structured.json",
  21. headers=headers,
  22. data=json.dumps({
  23. "market_name": market_name,
  24. "items": get_type_ids()})).json()
  25. def create_xlsx_file(market_name):
  26. workbook = xlsxwriter.Workbook(F"{args.name}.xlsx")
  27. worksheet = workbook.add_worksheet()
  28. row = 0
  29. col = 0
  30. index = 0
  31. items = get_json(market_name)["appraisal"]["items"]
  32. for item in items:
  33. if item['prices']['sell']['min'] != 0:
  34. index += 1
  35. print(index,
  36. "/",
  37. len(items),
  38. '=>',
  39. item['typeName'],
  40. '|',
  41. market_name,
  42. '|',
  43. item['prices']['sell']['min'])
  44. worksheet.write(row, col, str(item['typeName']))
  45. worksheet.write(row, col + 1, market_name)
  46. worksheet.write(row, col + 2, item['prices']['sell']['min'])
  47. row += 1
  48. workbook.close()
  49. if __name__ == '__main__':
  50. if args.market in ['jita', 'perimeter', 'universe', 'amarr', "dodixie", "hek", "rens"]:
  51. create_xlsx_file(market_name=args.market)
  52. else:
  53. print(F'Not found {args.market} in market')
  54. print(F'List, markets:', ', '.join(map(str, markets)))