Lotto2PY/lotto2py.py

96 lines
2.7 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
from datetime import datetime
wochentag = datetime.today().weekday()
wochentag = 2
if wochentag == 2:
a = "582"
elif wochentag == 5:
a = "581"
else:
quit()
telegram_chat_id = "322673713"
telegram_token ='680737840:AAEaa7Vxl_kZz_LWS1_S-lH6Eda7HXqu6Y4'
def notify_telegram(text):
params = {"parse_mode": "HTML", "chat_id": telegram_chat_id, "text": text}
url = f"https://api.telegram.org/bot{telegram_token}/sendMessage"
requests.post(url, params=params)
# Ziel-URL (ARDTeletext Mobilseite 581)
url = "https://www.ard-text.de/mobil/" + str(a)
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 = []
superzahl = None
spiel77 = []
super6 = []
datum_woche = None
Lottozahlen = {'Datum': '', 'Z1': '', 'Z2': '', 'Z3': '', 'Z4': '', 'Z5': '', 'Z6': '', 'Superzahl': '',
'Spiel77': '', 'Super6': ''}
# Wochentext extrahieren (z.B. "28. Woche / 09.07.25")
for line in text.splitlines():
if "Woche" in line and "/" in line:
datum_woche = line.strip()
break
# 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))
# Spiel 77 suchen (genau 7 Ziffern)
match_spiel77 = re.search(r"Spiel\s*77[^0-9]*((?:\d\s*){7})", text)
if match_spiel77:
#spiel77 = match_spiel77.group(1)
spiel77 = [int(n) for n in match_spiel77.group(1).split()]
# Super 6 suchen (genau 6 Ziffern)
match_super6 = re.search(r"Super\s*6[^0-9]*((?:\d\s*){6})", text)
if match_super6:
#super61 = match_super6.group(1)
super6 = [int(n) for n in match_super6.group(1).split()]
# Ausgabe
print("Datum / Woche:", datum_woche)
print("Gezogene Lottozahlen (6 aus 49):", lottozahlen)
print("Superzahl:", superzahl)
print("Spiel 77:", spiel77)
print("Super 6 :", super6)
lottozahlen.sort()
ab = 'Z'
cd = 1
for i in lottozahlen:
print(i)
ef=str((ab+str(cd)))
Lottozahlen[ef] = i
cd = cd +1
Lottozahlen['Datum'] = datum_woche
Lottozahlen['Superzahl'] = superzahl
Lottozahlen['Spiel77'] = spiel77
Lottozahlen['Super6'] = super6
print(Lottozahlen)
notify_telegram(str(Lottozahlen))