Lotto2PY/lotto2py.py
2025-07-14 16:36:25 +02:00

38 lines
No EOL
1.2 KiB
Python
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import requests
from bs4 import BeautifulSoup
import re
# Ziel-URL (ARDTeletext 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).