alle 4 Ziehungen eingepflegt
This commit is contained in:
parent
f53ed8ec37
commit
f88cd698a4
1 changed files with 194 additions and 99 deletions
293
lotto2py.py
293
lotto2py.py
|
|
@ -4,17 +4,6 @@ import re
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import pymysql
|
import pymysql
|
||||||
|
|
||||||
|
|
||||||
wochentag = datetime.today().weekday()
|
|
||||||
jahr = datetime.now().year
|
|
||||||
wochentag = 5
|
|
||||||
if wochentag == 2:
|
|
||||||
a = "582"
|
|
||||||
elif wochentag == 5:
|
|
||||||
a = "581"
|
|
||||||
else:
|
|
||||||
quit()
|
|
||||||
|
|
||||||
telegram_chat_id = "322673713"
|
telegram_chat_id = "322673713"
|
||||||
telegram_token ='680737840:AAEaa7Vxl_kZz_LWS1_S-lH6Eda7HXqu6Y4'
|
telegram_token ='680737840:AAEaa7Vxl_kZz_LWS1_S-lH6Eda7HXqu6Y4'
|
||||||
|
|
||||||
|
|
@ -22,105 +11,211 @@ def notify_telegram(text):
|
||||||
params = {"parse_mode": "HTML", "chat_id": telegram_chat_id, "text": text}
|
params = {"parse_mode": "HTML", "chat_id": telegram_chat_id, "text": text}
|
||||||
url = f"https://api.telegram.org/bot{telegram_token}/sendMessage"
|
url = f"https://api.telegram.org/bot{telegram_token}/sendMessage"
|
||||||
requests.post(url, params=params)
|
requests.post(url, params=params)
|
||||||
|
def Euro():
|
||||||
|
url = 'https://www.ard-text.de/mobil/583'
|
||||||
|
response = requests.get(url)
|
||||||
|
response.raise_for_status()
|
||||||
|
soup = BeautifulSoup(response.text, "html.parser")
|
||||||
|
ziffern = []
|
||||||
|
ZahlenEuro = {
|
||||||
|
'Freitag': {'Datum': '', 'Z1': '', 'Z2': '', 'Z3': '', 'Z4': '', 'Z5': '', 'Eurozahl1': '', 'Eurozahl2': ''},
|
||||||
|
'Dienstag': {'Datum': '', 'Z1': '', 'Z2': '', 'Z3': '', 'Z4': '', 'Z5': '', 'Eurozahl1': '', 'Eurozahl2': ''}}
|
||||||
|
Tag = 'Freitag'
|
||||||
|
for b in soup.find("p", string=lambda s: s and "freitag" in s.lower()):
|
||||||
|
ZahlenEuro[Tag]['Datum'] = b
|
||||||
|
tabelle = b.find_parent().find_next_sibling("table")
|
||||||
|
a = 1
|
||||||
|
for n in tabelle.find_all("td"):
|
||||||
|
c = (n.get_text(strip=True))
|
||||||
|
b = 'Z' + str(a)
|
||||||
|
ZahlenEuro[Tag][b] = int(c)
|
||||||
|
a = a + 1
|
||||||
|
for x in soup.find("p", string=lambda s: s and "eurozahlen" in s.lower()):
|
||||||
|
eurotabelle = x.find_parent().find_next_sibling("table")
|
||||||
|
aa = 1
|
||||||
|
for m in eurotabelle.find_all("td"):
|
||||||
|
c = (m.get_text(strip=True))
|
||||||
|
bb = 'Eurozahl' + str(aa)
|
||||||
|
ZahlenEuro[Tag][bb] = int(c)
|
||||||
|
aa = aa + 1
|
||||||
|
Tag = 'Dienstag'
|
||||||
|
for b in soup.find("p", string=lambda s: s and "dienstag" in s.lower()):
|
||||||
|
ZahlenEuro[Tag]['Datum'] = b
|
||||||
|
tabelle = b.find_parent().find_next_sibling("table")
|
||||||
|
a = 1
|
||||||
|
print(b)
|
||||||
|
for n in tabelle.find_all("td"):
|
||||||
|
c = (n.get_text(strip=True))
|
||||||
|
b = 'Z' + str(a)
|
||||||
|
ZahlenEuro[Tag][b] = int(c)
|
||||||
|
a = a + 1
|
||||||
|
eurozahlen_tags = soup.find_all("b", string=lambda s: s and "eurozahlen" in s.lower())
|
||||||
|
|
||||||
# Ziel-URL (ARD‑Teletext Mobilseite 581)
|
aa = 1
|
||||||
|
if len(eurozahlen_tags) >= 2:
|
||||||
|
eurozahlen_table_2 = eurozahlen_tags[1].find_next("table")
|
||||||
|
eurozahlen_2 = [td.text.strip() for td in eurozahlen_table_2.find_all("td")]
|
||||||
|
for i in eurozahlen_2:
|
||||||
|
bb = 'Eurozahl' + str(aa)
|
||||||
|
ZahlenEuro[Tag][bb] = int(i)
|
||||||
|
aa = aa + 1
|
||||||
|
return ZahlenEuro
|
||||||
|
def Normalziehung(a):
|
||||||
|
wochentag = datetime.today().weekday()
|
||||||
|
jahr = datetime.now().year
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
url = "https://www.ard-text.de/mobil/" + str(a)
|
lottozahlen.sort()
|
||||||
|
ab = 'Z'
|
||||||
|
cd = 1
|
||||||
|
subber6 = ''
|
||||||
|
game77 = ''
|
||||||
|
for i in super6:
|
||||||
|
subber6 = subber6 + str(i)
|
||||||
|
for i in spiel77:
|
||||||
|
game77 = game77 + str(i)
|
||||||
|
|
||||||
headers = {
|
for i in lottozahlen:
|
||||||
"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"
|
|
||||||
}
|
ef = str((ab + str(cd)))
|
||||||
|
Lottozahlen[ef] = i
|
||||||
|
cd = cd + 1
|
||||||
|
Lottozahlen['Datum'] = str(jahr) + ' / ' + str(datum_woche)
|
||||||
|
Lottozahlen['Superzahl'] = superzahl
|
||||||
|
Lottozahlen['Spiel77'] = int(game77)
|
||||||
|
Lottozahlen['Super6'] = int(subber6)
|
||||||
|
|
||||||
|
|
||||||
response = requests.get(url, headers=headers)
|
|
||||||
response.raise_for_status()
|
|
||||||
|
|
||||||
soup = BeautifulSoup(response.text, "html.parser")
|
return Lottozahlen
|
||||||
|
def SQLnorm(data):
|
||||||
|
connection = pymysql.connect(db="hubobel",
|
||||||
|
user="hubobel",
|
||||||
|
passwd="polier2003",
|
||||||
|
host='10.0.1.123', charset='utf8')
|
||||||
|
cursor = connection.cursor()
|
||||||
|
|
||||||
# Den relevanten Abschnitt als Text extrahieren
|
sql = "INSERT INTO `6aus49`(`datum`, `z1`, `z2`, `z3`, `z4`, `z5`, `z6`, `sz`, `super6`, `spiel77`) VALUES" \
|
||||||
text = soup.get_text(separator="\n")
|
" ('" + str(data['Datum']) + "','" + str(data['Z1']) + "','" + str(data['Z2']) + "','" + str(data['Z3']) + \
|
||||||
|
"','" + str(data['Z4']) + "','" + str(data['Z5']) + "','" + str(data['Z6']) + "','" + str(data['Superzahl']) + \
|
||||||
|
"','" + str(data['Super6']) + "','" + str(data['Spiel77']) + "')"
|
||||||
|
sql_q = "SELECT * FROM 6aus49 WHERE datum like '%" + data['Datum'] + "%'"
|
||||||
|
resp = cursor.execute(sql_q)
|
||||||
|
if resp == 0:
|
||||||
|
cursor.execute(sql)
|
||||||
|
|
||||||
# Lottozahlen: 6 aus 49, Zusatzzahl und Superzahl
|
connection.commit()
|
||||||
lottozahlen = []
|
cursor.close()
|
||||||
superzahl = None
|
connection.close()
|
||||||
spiel77 = []
|
def SQLdienstag(data):
|
||||||
super6 = []
|
connection = pymysql.connect(db="hubobel",
|
||||||
datum_woche = None
|
user="hubobel",
|
||||||
Lottozahlen = {'Datum': '', 'Z1': '', 'Z2': '', 'Z3': '', 'Z4': '', 'Z5': '', 'Z6': '', 'Superzahl': '',
|
passwd="polier2003",
|
||||||
'Spiel77': '', 'Super6': ''}
|
host='10.0.1.123', charset='utf8')
|
||||||
|
cursor = connection.cursor()
|
||||||
|
|
||||||
# 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")
|
sql = "INSERT INTO `euro`(`datum`, `z1`, `z2`, `z3`, `z4`, `z5`, `sz1`, `sz2`) VALUES" \
|
||||||
match_super = re.search(r"Superzahl[^0-9]*([0-9]{1,2})", text)
|
" ('" + str(data['Datum']) + "','" + str(data['Z1']) + "','" + str(data['Z2']) + "','" + str(data['Z3']) + \
|
||||||
if match_super:
|
"','" + str(data['Z4']) + "','" + str(data['Z5']) + "','" + str(data['Eurozahl1']) + "','" + str(
|
||||||
superzahl = int(match_super.group(1))
|
data['Eurozahl2']) + "')"
|
||||||
|
sql_q = "SELECT * FROM euro WHERE datum like '%" + data['Datum'] + "%'"
|
||||||
|
resp = cursor.execute(sql_q)
|
||||||
|
if resp == 0:
|
||||||
|
cursor.execute(sql)
|
||||||
|
print(resp)
|
||||||
|
connection.commit()
|
||||||
|
cursor.close()
|
||||||
|
connection.close()
|
||||||
|
def SQLfreitag(data):
|
||||||
|
connection = pymysql.connect(db="hubobel",
|
||||||
|
user="hubobel",
|
||||||
|
passwd="polier2003",
|
||||||
|
host='10.0.1.123', charset='utf8')
|
||||||
|
cursor = connection.cursor()
|
||||||
|
|
||||||
# Spiel 77 suchen (genau 7 Ziffern)
|
sql = "INSERT INTO `euro`(`datum`, `z1`, `z2`, `z3`, `z4`, `z5`, `sz1`, `sz2`) VALUES" \
|
||||||
match_spiel77 = re.search(r"Spiel\s*77[^0-9]*((?:\d\s*){7})", text)
|
" ('" + str(data['Datum']) + "','" + str(data['Z1']) + "','" + str(data['Z2']) + "','" + str(data['Z3']) + \
|
||||||
if match_spiel77:
|
"','" + str(data['Z4']) + "','" + str(data['Z5']) + "','" + str(data['Eurozahl1']) + "','" + str(
|
||||||
#spiel77 = match_spiel77.group(1)
|
data['Eurozahl2']) + "')"
|
||||||
spiel77 = [int(n) for n in match_spiel77.group(1).split()]
|
sql_q = "SELECT * FROM euro WHERE datum like '%" + data['Datum'] + "%'"
|
||||||
# Super 6 suchen (genau 6 Ziffern)
|
resp = cursor.execute(sql_q)
|
||||||
match_super6 = re.search(r"Super\s*6[^0-9]*((?:\d\s*){6})", text)
|
if resp == 0:
|
||||||
if match_super6:
|
cursor.execute(sql)
|
||||||
#super61 = match_super6.group(1)
|
print(resp)
|
||||||
super6 = [int(n) for n in match_super6.group(1).split()]
|
connection.commit()
|
||||||
|
cursor.close()
|
||||||
|
connection.close()
|
||||||
|
|
||||||
# Ausgabe
|
wochentag = datetime.today().weekday()
|
||||||
print("Datum / Woche:", str(jahr) + ' / ' + str(datum_woche))
|
wochentag = 1
|
||||||
print("Gezogene Lottozahlen (6 aus 49):", lottozahlen)
|
|
||||||
print("Superzahl:", superzahl)
|
|
||||||
print("Spiel 77:", spiel77)
|
|
||||||
print("Super 6 :", super6)
|
|
||||||
|
|
||||||
lottozahlen.sort()
|
if wochentag == 2:
|
||||||
ab = 'Z'
|
Zahl = Normalziehung(582)
|
||||||
cd = 1
|
SQLnorm(Zahl)
|
||||||
subber6 =''
|
notify_telegram(str(Zahl))
|
||||||
game77=''
|
elif wochentag == 5:
|
||||||
for i in super6:
|
Zahl = Normalziehung(581)
|
||||||
subber6 = subber6 + str(i)
|
SQLnorm(Zahl)
|
||||||
for i in spiel77:
|
notify_telegram(str(Zahl))
|
||||||
game77 = game77 + str(i)
|
elif wochentag == 1:
|
||||||
|
Zahl = Euro()
|
||||||
for i in lottozahlen:
|
SQLdienstag(Zahl['Dienstag'])
|
||||||
print(i)
|
notify_telegram(str(Zahl['Dienstag']))
|
||||||
ef=str((ab+str(cd)))
|
elif wochentag == 4:
|
||||||
Lottozahlen[ef] = i
|
Zahl = Euro()
|
||||||
cd = cd +1
|
SQLfreitag(Zahl['Freitag'])
|
||||||
Lottozahlen['Datum'] = str(jahr) + ' / ' + str(datum_woche)
|
notify_telegram(str(Zahl['Freitag']))
|
||||||
Lottozahlen['Superzahl'] = superzahl
|
else:
|
||||||
Lottozahlen['Spiel77'] = int(game77)
|
quit()
|
||||||
Lottozahlen['Super6'] = int(subber6)
|
|
||||||
print(Lottozahlen)
|
|
||||||
data = Lottozahlen
|
|
||||||
connection = pymysql.connect(db="hubobel",
|
|
||||||
user="hubobel",
|
|
||||||
passwd="polier2003",
|
|
||||||
host='10.0.1.123',charset='utf8')
|
|
||||||
cursor = connection.cursor()
|
|
||||||
|
|
||||||
sql = "INSERT INTO `6aus49`(`datum`, `z1`, `z2`, `z3`, `z4`, `z5`, `z6`, `sz`, `super6`, `spiel77`) VALUES" \
|
|
||||||
" ('" + str(data['Datum']) + "','" + str(data['Z1']) + "','" + str(data['Z2']) + "','" + str(data['Z3']) + \
|
|
||||||
"','" + str(data['Z4']) + "','" + str(data['Z5']) + "','" + str(data['Z6']) + "','" + str(data['Superzahl']) + \
|
|
||||||
"','" + str(data['Super6']) + "','" + str(data['Spiel77']) + "')"
|
|
||||||
sql_q = "SELECT * FROM 6aus49 WHERE datum like '%" + data['Datum'] + "%'"
|
|
||||||
resp = cursor.execute(sql_q)
|
|
||||||
if resp == 0:
|
|
||||||
cursor.execute(sql)
|
|
||||||
|
|
||||||
connection.commit()
|
|
||||||
cursor.close()
|
|
||||||
connection.close()
|
|
||||||
|
|
||||||
notify_telegram(str(Lottozahlen))
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue