los gehts
This commit is contained in:
parent
6ccb2b5337
commit
f3d6b2961f
1 changed files with 38 additions and 0 deletions
38
lotto2py.py
Normal file
38
lotto2py.py
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
import re
|
||||
|
||||
# Ziel-URL (ARD‑Teletext Mobilseite 581)
|
||||
url = "https://www.ard-text.de/mobil/582"
|
||||
|
||||
headers = {
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"
|
||||
}
|
||||
|
||||
response = requests.get(url, headers=headers)
|
||||
response.raise_for_status()
|
||||
|
||||
soup = BeautifulSoup(response.text, "html.parser")
|
||||
|
||||
# Den relevanten Abschnitt als Text extrahieren
|
||||
text = soup.get_text(separator="\n")
|
||||
|
||||
# Lottozahlen: 6 aus 49, Zusatzzahl und Superzahl
|
||||
lottozahlen = []
|
||||
zusatzzahl = None
|
||||
superzahl = None
|
||||
|
||||
# Regex: Hauptzahlen finden (z. B. Zeile enthält "11 20 28 30 35 41")
|
||||
match_haupt = re.search(r"\s(\d{1,2}(?:\s+\d{1,2}){5})\s", text)
|
||||
if match_haupt:
|
||||
lottozahlen = [int(n) for n in match_haupt.group(1).split()]
|
||||
|
||||
# Superzahl (z. B. nach dem Begriff "Superzahl")
|
||||
match_super = re.search(r"Superzahl[^0-9]*([0-9]{1,2})", text)
|
||||
if match_super:
|
||||
superzahl = int(match_super.group(1))
|
||||
|
||||
# Ausgabe der Variablen
|
||||
print("Gezogene Lottozahlen (6 aus 49):", lottozahlen)
|
||||
print("Superzahl:", superzahl)
|
||||
# ARD-Teletext führt in 581 keine Zusatzzahl auf – ggf. gleichen Ablauf auf Seite 582 (Mittwoch).
|
||||
Loading…
Add table
Add a link
Reference in a new issue