Skip to content

Commit 83d01bb

Browse files
committed
Fix TH pegel page scraping
1 parent 2374368 commit 83d01bb

4 files changed

Lines changed: 12 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.0.8 (2025-12-09)
2+
### Fixed
3+
- Fix TH pegel page scraping
4+
15
## 1.0.7 (2025-11-23)
26
### Fixed
37
- Fix HE without flow

docs/update_pegel_list.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ def get_th_stations() -> tuple[str, str]:
411411
trs = tbody.find_all("tr")
412412
for row in trs:
413413
tds = row.find_all("td")
414-
if len(tds) > 10:
414+
if len(tds) > 3:
415415
ident = "TH_" + tds[1].getText().strip()
416416
name = tds[2].getText().strip() + " / " + tds[3].getText().strip()
417417
stations.append((ident, name))

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "lhpapi"
7-
version = "1.0.7"
7+
version = "1.0.8"
88
authors = [
99
{ name="stephan192", email="stephan192@outlook.com" },
1010
]

src/lhpapi/th_api.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def init_TH(ident: str) -> StaticData: # pylint: disable=invalid-name
2323
# Parse data
2424
for row in trs:
2525
tds = row.find_all("td")
26-
if len(tds) > 10:
26+
if len(tds) > 3:
2727
if tds[1].getText().strip() != ident[3:]:
2828
continue
2929
links = tds[1].find_all("a")
@@ -49,10 +49,10 @@ def update_TH(static_data: StaticData) -> DynamicData: # pylint: disable=invali
4949
# Parse data
5050
for row in trs:
5151
tds = row.find_all("td")
52-
if len(tds) > 10:
52+
if len(tds) > 11:
5353
if tds[1].getText().strip() != static_data.ident[3:]:
5454
continue
55-
if str(tds[6]).find("Hochwassermeldepegel") != -1:
55+
if str(tds[7]).find("Hochwassermeldepegel") != -1:
5656
if "w3-purple" in row["class"]:
5757
stage = 4
5858
elif "w3-red" in row["class"]:
@@ -66,10 +66,10 @@ def update_TH(static_data: StaticData) -> DynamicData: # pylint: disable=invali
6666
else:
6767
stage = None
6868
last_update = convert_to_datetime(
69-
tds[7].getText().strip(), "%d.%m.%Y %H:%M"
69+
tds[8].getText().strip(), "%d.%m.%Y %H:%M"
7070
)
71-
level = convert_to_float(tds[8].getText().strip(), True)
72-
flow = convert_to_float(tds[10].getText().strip(), True)
71+
level = convert_to_float(tds[9].getText().strip(), True)
72+
flow = convert_to_float(tds[11].getText().strip(), True)
7373
return DynamicData(
7474
level=level, stage=stage, flow=flow, last_update=last_update
7575
)

0 commit comments

Comments
 (0)