-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeneral.py
31 lines (27 loc) · 1.17 KB
/
general.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
from util import UrlProvider, Resources
from browser import Browser
from bs4 import BeautifulSoup
class General():
"""
This class is used for general actions
"""
def __init__(self, browser: Browser):
# Get Instance of browser
self.browser = browser
def get_resources(self):
"""
:return: All Resources Avaialable
"""
print('Getting resources')
# Redirect Browser to resources page
self.browser.open_page(UrlProvider().get_page_url('resources'))
# Scrap the page
soup = BeautifulSoup(self.browser.page_source(), 'lxml')
# Get Resources with Scraping as Intager
metal = int(soup.find(id='resources_metal').text.replace('.', ''))
crystal = int(soup.find(id='resources_crystal').text.replace('.', ''))
deuterium = int(soup.find(id='resources_deuterium').text.replace('.', ''))
energy = int(soup.find(id='resources_energy').text.replace('.', ''))
dark_matter = int(soup.find(id='resources_darkmatter').text.replace('.', ''))
# Return Resource Object with all value
return (Resources(metal, crystal, deuterium, energy, dark_matter)).__str__()