Skip to content

Commit

Permalink
🔀 Merge branch 'main' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
jh0ker committed Jan 25, 2024
2 parents 7c61263 + 6c96cd1 commit 7595909
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
6 changes: 3 additions & 3 deletions ddj_cloud/scrapers/talsperren/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Load lxml because for some reason bs4 doesn't find it otherwise?
from lxml import etree
from lxml import etree # noqa: F401

# Ensure that federation subclasses are loaded
from . import federations
from . import federations # noqa: F401

# Ensure that exporter subclasses are loaded
from . import exporters
from . import exporters # noqa: F401
25 changes: 20 additions & 5 deletions ddj_cloud/scrapers/talsperren/federations/wahnbach.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ def _get_reservoir_records(
ts = heading_ts.replace(tzinfo=TZ_BERLIN)

# Parse following nodes
following_nodes = heading.find_next_siblings(limit=3)
following_nodes = heading.find_next_siblings(limit=1)
assert following_nodes, "No following nodes found"
assert len(following_nodes) >= 3, "Not enough following nodes found"
assert len(following_nodes) >= 1, "Not enough following nodes found"

# Parse content
content_match = re.match(
content_match = re.search(
r"Stauinhalt:\s([\d,]+)\sMio.\s?m[3³]",
following_nodes[1].text.strip(),
following_nodes[0].text.strip(),
)
assert content_match, "No match found for content"
content_mio_m3 = float(content_match.group(1).replace(",", "."))
Expand All @@ -95,6 +95,22 @@ def get_data(self, **kwargs) -> Iterable[ReservoirRecord]:
"""
Example HTML:
<div class="ce-bodytext">
<h5><br> Aktuelle Daten vom 22. Januar 2024:</h5>
<p>Staupegel: 122,88 mNN<br> Stauinhalt: 38,516 Mio.&nbsp;m<sup>3</sup><br> Füllungsgrad: 94,16 %</p>
<h5><br> Daten vom 15. Januar 2024:</h5>
<p>Staupegel: 123,12 mNN<br> Stauinhalt: 38,890 Mio.&nbsp;m<sup>3</sup><br> Füllungsgrad: 95,29 %</p>
<h5><br> Daten vom 08. Januar 2024:</h5>
<p>Staupegel: 123,21 mNN<br> Stauinhalt: 39,155 Mio.&nbsp;m<sup>3</sup><br> Füllungsgrad: 95,72 %</p>
<p>&nbsp;</p>
<h5>Bisherige Tages-Spitzenabgaben:</h5>
<p>(Eine normale Abgabemenge liegt bei zirka 130.000 m³/d.)</p>
<p>193 400 m³ am 03. August 1990<br> 189.450 m³ am 07. August 2020<br> 189.062 m³ am 06. August 2020</p>
<p>&nbsp;</p>
</div>
OLD:
<div class="ce-bodytext">
<h5>Aktuelle Daten vom 30. Oktober 2023:</h5>
<p>Staupegel: 119,93 mNN</p>
Expand All @@ -117,5 +133,4 @@ def get_data(self, **kwargs) -> Iterable[ReservoirRecord]:
<p>193 400 m³ am 03. August 1990<br> 189.450 m³ am 07. August 2020<br> 189.062 m³ am 06. August 2020</p>
<p>&nbsp;</p>
</div>
"""

0 comments on commit 7595909

Please sign in to comment.