Skip to content

Commit

Permalink
Merge pull request #1293 from 5ila5/fix_awigo_de
Browse files Browse the repository at this point in the history
fix awigo using badbergen instead of bergen
  • Loading branch information
5ila5 authored Sep 29, 2023
2 parents fa9ea8e + 21c76cf commit 7d4900d
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
import urllib

import requests
Expand All @@ -12,6 +13,7 @@
"Bippen Am Bad 4": {"ort": "Bippen", "strasse": "Am Bad", "hnr": 4},
"fürstenau, Am Gültum, 9": {"ort": "Fürstenau", "strasse": "Am Gültum", "hnr": 9},
"Melle, Allee, 78-80": {"ort": "Melle", "strasse": "Allee", "hnr": "78-80"},
"Berge": {"ort": "Berge", "strasse": "Poststr.", "hnr": 3},
}


Expand All @@ -27,6 +29,13 @@
API_URL = "https://www.awigo.de/index.php"


def compare_cities(a: str, b: str) -> bool:
return (
re.sub(r"\([0-9]+\)", "", a.lower()).strip()
== re.sub(r"\([0-9]+\)", "", b.lower()).strip()
)


class Source:
def __init__(self, ort: str, strasse: str, hnr: str | int):
self._ort: str = str(ort)
Expand All @@ -52,7 +61,7 @@ def fetch(self):

soup = BeautifulSoup(r.text, features="html.parser")
for option in soup.findAll("option"):
if self._ort.lower().strip() in option.text.lower().strip():
if compare_cities(self._ort, option.text):
args["calendar[cityID]"] = option.get("value")
break
if "calendar[cityID]" not in args:
Expand Down

0 comments on commit 7d4900d

Please sign in to comment.