|
|
@ -69,6 +69,19 @@ def init(key, modus, host, headers): |
|
|
|
|
|
|
|
|
|
|
|
return name, value |
|
|
|
return name, value |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def read_file(jahr): |
|
|
|
|
|
|
|
''' Liest Daten aus muell<jahr>.csv und liefert ggf. Ergebnis zurück''' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
antwort_liste = None |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
f = open(f'muell{jahr}.csv', 'rb') |
|
|
|
|
|
|
|
antwort = str(f.read()) |
|
|
|
|
|
|
|
antwort_liste = antwort[antwort.find('Biom'):].strip("'").replace('\\n', '\n').split('\n') |
|
|
|
|
|
|
|
except FileNotFoundError: |
|
|
|
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return antwort_liste |
|
|
|
|
|
|
|
|
|
|
|
# Variablen |
|
|
|
# Variablen |
|
|
|
key = 'e21758b9c711463552fb9c70ac7d4273' |
|
|
|
key = 'e21758b9c711463552fb9c70ac7d4273' |
|
|
|
modus = 'd6c5855a62cf32a4dadbc2831f0f295f' |
|
|
|
modus = 'd6c5855a62cf32a4dadbc2831f0f295f' |
|
|
@ -106,35 +119,31 @@ muell_arten = [ |
|
|
|
'Schadstoffmobil', |
|
|
|
'Schadstoffmobil', |
|
|
|
] |
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
tomorrow = (datetime.now() + timedelta(1)).strftime('%d.%m.%Y') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# __main__ |
|
|
|
# __main__ |
|
|
|
config = readConfig() |
|
|
|
antwort_liste = read_file(current_year) |
|
|
|
postdata['f_id_kommune'] = config['kommune'] |
|
|
|
if antwort_liste == None: |
|
|
|
postdata['f_id_strasse'] = config['strasse'] |
|
|
|
# Keine vernünftigen Daten, ergo mal gucken, was die Webseite ergibt |
|
|
|
|
|
|
|
config = readConfig() |
|
|
|
(name, value) = init(key, modus, host, headers) |
|
|
|
postdata['f_id_kommune'] = config['kommune'] |
|
|
|
if name != None and value != None: |
|
|
|
postdata['f_id_strasse'] = config['strasse'] |
|
|
|
postdata[name] = value |
|
|
|
|
|
|
|
|
|
|
|
(name, value) = init(key, modus, host, headers) |
|
|
|
http = httplib2.Http() |
|
|
|
if name != None and value != None: |
|
|
|
(resp, content) = http.request(url, "POST", headers = headers, body = urllib.parse.urlencode(postdata)) |
|
|
|
postdata[name] = value |
|
|
|
|
|
|
|
|
|
|
|
antwort = str(content) |
|
|
|
http = httplib2.Http() |
|
|
|
antwort_liste = antwort[antwort.find('Biom'):].strip("'").replace('\\n', '\n').split('\n') |
|
|
|
(resp, content) = http.request(url, "POST", headers = headers, body = urllib.parse.urlencode(postdata)) |
|
|
|
|
|
|
|
|
|
|
|
if antwort_liste[0] == '': |
|
|
|
antwort = str(content) |
|
|
|
# Keine vernünftigen Daten, ergo mal gucken, was in der Datei steht |
|
|
|
f = open(f'muell{current_year}.csv', 'wb') |
|
|
|
try: |
|
|
|
f.write(content) |
|
|
|
f = open('muell.csv', 'rb') |
|
|
|
f.close() |
|
|
|
antwort = str(f.read()) |
|
|
|
antwort_liste = antwort[antwort.find('Biom'):].strip("'").replace('\\n', '\n').split('\n') |
|
|
|
antwort_liste = antwort[antwort.find('Biom'):].strip("'").replace('\\n', '\n').split('\n') |
|
|
|
|
|
|
|
except FileNotFoundError: |
|
|
|
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
daten = set(antwort_liste) |
|
|
|
daten = set(antwort_liste) |
|
|
|
|
|
|
|
|
|
|
|
for datum in daten: |
|
|
|
for datum in daten: |
|
|
|
|
|
|
|
tomorrow = (datetime.now() + timedelta(1)).strftime('%d.%m.%Y') |
|
|
|
datum = datum.split(';') |
|
|
|
datum = datum.split(';') |
|
|
|
l_muell = get_index_positions(datum, tomorrow) |
|
|
|
l_muell = get_index_positions(datum, tomorrow) |
|
|
|
if len(l_muell) > 0: |
|
|
|
if len(l_muell) > 0: |
|
|
|