diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/poznan_pl.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/poznan_pl.py index 3435c25c6..0ad7c1059 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/poznan_pl.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/poznan_pl.py @@ -48,34 +48,33 @@ def fetch(self) -> list[Collection]: r = requests.post(f"{API_URL}", data) r.raise_for_status() - # Fix their broken html table - fixed_text = re.sub(r"\s*\s*\s*\s*\s*\s* 12: - continue - for cell_index, cell in enumerate(row.find_all("td")): + for row_index, row in enumerate(trs[1:]): + all_cells = row.find_all("td") + collection_name = all_cells[0].text.strip() + # iterate over all rows with dates without collection name + for cell_index, cell in enumerate(all_cells[1:]): if ( - cell_index == 0 - or not isinstance(cell, Tag) + not isinstance(cell, Tag) + or not cell['data-value'] == formatted_date or not cell.text.strip() ): continue @@ -84,8 +83,8 @@ def fetch(self) -> list[Collection]: day = day.strip() entries.append( Collection( - datetime.date(year, row_index, int(day)), - name_map[cell_index], + datetime.date(year, month, int(day)), + collection_name, ICON_MAP[cell_index], ) )