storage.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. """Profile class"""
  2. import re
  3. from bs4 import BeautifulSoup
  4. from . import MIDDLEWARE
  5. class Storage(object):
  6. """Wrapper class for profile"""
  7. @staticmethod
  8. def info():
  9. """Get profile"""
  10. path = 'storage'
  11. response = MIDDLEWARE.get(path)
  12. soup = BeautifulSoup(response, 'html.parser')
  13. keys = {
  14. 'oil': 3,
  15. 'ore': 4,
  16. 'uranium': 11,
  17. 'diamonds': 15,
  18. 'liquid_oxygen': 21,
  19. 'helium-3': 24,
  20. 'rivalium': 26,
  21. 'antirad': 13,
  22. 'energy_drink': 17,
  23. 'spacerockets': 20,
  24. 'lss': 25,
  25. 'tanks': 2,
  26. 'aircrafts': 1,
  27. 'missiles': 14,
  28. 'bombers': 16,
  29. 'battleships': 18,
  30. 'laser_drones': 27,
  31. 'moon_tanks': 22,
  32. 'space_stations': 23
  33. }
  34. storage = {}
  35. for key, item_id in keys.items():
  36. storage[key] = int(
  37. soup.find('span', {'urlbar' : item_id}).text.replace('.', '')
  38. )
  39. storage['{}_max'.format(key)] = int(
  40. soup.find('span', {'urlbar' : item_id})['maxstore']
  41. )
  42. return storage