Private Eigenschaften in Klasse Muell
This commit is contained in:
parent
d6cc9b974f
commit
a964b2b5bc
@ -32,19 +32,21 @@ from pathlib import Path
|
||||
|
||||
class Muell:
|
||||
|
||||
def __init__(self):
|
||||
|
||||
# Variablen
|
||||
key = 'e21758b9c711463552fb9c70ac7d4273'
|
||||
modus = 'd6c5855a62cf32a4dadbc2831f0f295f'
|
||||
self.__key = 'e21758b9c711463552fb9c70ac7d4273'
|
||||
self.__modus = 'd6c5855a62cf32a4dadbc2831f0f295f'
|
||||
|
||||
host = 'api.abfall.io'
|
||||
self.__host = 'api.abfall.io'
|
||||
|
||||
url = f'https://{host}/?key={key}&modus={modus}&waction=export_csv'
|
||||
export_als = f"{{'action':'{url}','target':''}}"
|
||||
self.__url = f'https://{self.__host}/?key={self.__key}&modus={self.__modus}&waction=export_csv'
|
||||
self.__export_als = f"{{'action':'{self.__url}','target':''}}"
|
||||
|
||||
current_year = datetime.today().year
|
||||
zeitraum = f'{current_year}0101-{current_year}1231'
|
||||
self.__current_year = datetime.today().year
|
||||
self.__zeitraum = f'{self.__current_year}0101-{self.__current_year}1231'
|
||||
|
||||
postdata = {
|
||||
self.__postdata = {
|
||||
'f_id_abfalltyp_0': '50',
|
||||
'f_id_abfalltyp_1': '161',
|
||||
'f_id_abfalltyp_2': '53',
|
||||
@ -52,11 +54,11 @@ class Muell:
|
||||
'f_id_abfalltyp_4': '169',
|
||||
'f_abfallarten_index_max': '5',
|
||||
'f_abfallarten': '50,161,53,187',
|
||||
'f_zeitraum': zeitraum,
|
||||
'f_export_als': export_als,
|
||||
'f_zeitraum': self.__zeitraum,
|
||||
'f_export_als': self.__export_als,
|
||||
}
|
||||
|
||||
headers = {
|
||||
self.__headers = {
|
||||
'User-Agent': 'Mozilla/5.0 (Linux; x68_64; x64; rv:88.0) Gecko/20100101 Firefox/88.0',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
}
|
||||
@ -82,12 +84,12 @@ class Muell:
|
||||
|
||||
return config
|
||||
|
||||
def __init(self):
|
||||
def __start(self):
|
||||
''' Initialisiert das System und sucht entsprechende Daten heraus '''
|
||||
|
||||
url = f'https://{self.host}/?key={self.key}&modus={self.modus}&waction=init'
|
||||
url = f'https://{self.__host}/?key={self.__key}&modus={self.__modus}&waction=init'
|
||||
http = httplib2.Http()
|
||||
(resp, content) = http.request(url, "POST", headers = self.headers, body = urllib.parse.urlencode(self.postdata))
|
||||
(resp, content) = http.request(url, "POST", headers = self.__headers, body = urllib.parse.urlencode(self.__postdata))
|
||||
|
||||
result = re.findall(r"<input .*?name=.*? value=.*?/>", str(content))
|
||||
|
||||
@ -128,7 +130,7 @@ class Muell:
|
||||
return (antwort_liste, headline)
|
||||
|
||||
def get_data(self):
|
||||
(antwort_liste, headline) = self.__read_file(self.current_year)
|
||||
(antwort_liste, headline) = self.__read_file(self.__current_year)
|
||||
config = self.__readConfig()
|
||||
|
||||
if not antwort_liste:
|
||||
@ -136,18 +138,18 @@ class Muell:
|
||||
self.postdata['f_id_kommune'] = config['kommune']
|
||||
self.postdata['f_id_strasse'] = config['strasse']
|
||||
|
||||
(name, value) = self.__init()
|
||||
(name, value) = self.__start()
|
||||
if name != None and value != None:
|
||||
self.postdata[name] = value
|
||||
|
||||
http = httplib2.Http()
|
||||
(resp, content) = http.request(self.url, "POST", headers = self.headers, body = urllib.parse.urlencode(self.postdata))
|
||||
(resp, content) = http.request(self.__url, "POST", headers = self.__headers, body = urllib.parse.urlencode(self.__postdata))
|
||||
|
||||
antwort = str(content)
|
||||
f = open(f'muell{self.current_year}.csv', 'wb')
|
||||
f = open(f'muell{self._current_year}.csv', 'wb')
|
||||
f.write(content)
|
||||
f.close()
|
||||
(antwort_liste, headline) = self.__read_file(self.current_year)
|
||||
(antwort_liste, headline) = self.__read_file(self.__current_year)
|
||||
|
||||
tomorrow = (datetime.now() + timedelta(1)).strftime('%d.%m.%Y')
|
||||
index = set();
|
||||
@ -202,4 +204,3 @@ class Muell:
|
||||
|
||||
if ausgabe is not None:
|
||||
print(f'{ausgabe}')
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user