From 7e999afe3e6a516a8675b79e6fb80d87667a5edc Mon Sep 17 00:00:00 2001 From: hubobel Date: Mon, 14 Jul 2025 17:57:07 +0200 Subject: [PATCH] =?UTF-8?q?aus=20dem=20alten=20Projekt=20=C3=BCbertragen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Pool_old/Lotto2SQL.py | 160 +++++++++++++++++++++++++++++++++++++++ Pool_old/Lotto2SQL_V2.py | 116 ++++++++++++++++++++++++++++ Pool_old/lotto24.py | 70 +++++++++++++++++ 3 files changed, 346 insertions(+) create mode 100644 Pool_old/Lotto2SQL.py create mode 100644 Pool_old/Lotto2SQL_V2.py create mode 100644 Pool_old/lotto24.py diff --git a/Pool_old/Lotto2SQL.py b/Pool_old/Lotto2SQL.py new file mode 100644 index 0000000..640aa39 --- /dev/null +++ b/Pool_old/Lotto2SQL.py @@ -0,0 +1,160 @@ +import pymysql +import bs4 as bs +import requests +import time + +connection = pymysql.connect(db="hubobel", + user="hubobel", + passwd="polier2003", + host='10.0.1.123',charset='utf8') +cursor = connection.cursor() + + +requests.packages.urllib3.disable_warnings() +sauce = requests.get('https://lotto.web.de/webshop/product/eurojackpot/result', verify=False) +soup = bs.BeautifulSoup(sauce.text, 'lxml') +#print(soup) +ZahlenEuro = {'Datum': '', 'Z1': '', 'Z2': '', 'Z3': '', 'Z4': '', 'Z5': '', 'Eurozahl1': '', 'Eurozahl2': ''} +a = 1 +daten = soup.find_all('div', class_="winning-numbers__number") +for i in daten: + #print(i.text) + if a <= 5: + ZahlenEuro['Z' + str(a)] = int(i.text) + elif a == 6: + ZahlenEuro['Eurozahl1'] = int(i.text) + elif a == 7: + ZahlenEuro['Eurozahl2'] = int(i.text) + a = a + 1 +#print(ZahlenEuro) +daten = soup.find_all('h2', class_="strong hidden-xs") +#print(daten) +for i in daten: + date = i.text + date = date.replace(' ', '') + date = date.replace('\n', '') + +start = (date.find('dem')) + 4 +ende = (date.find('(Alle')) +ZahlenEuro['Datum'] = date[start:ende] +#print(ZahlenEuro) + +requests.packages.urllib3.disable_warnings() +sauce = requests.get('https://lotto.web.de/webshop/product/lottonormal/result', verify=False) +soup = bs.BeautifulSoup(sauce.text, 'lxml') + +Lottozahlen = {'Datum': '', 'Z1': '', 'Z2': '', 'Z3': '', 'Z4': '', 'Z5': '', 'Z6': '', 'Superzahl': '', + 'Spiel77': '', 'Super6': ''} +daten = soup.find_all('div', class_="winning-numbers__number") +zahlen = [] +for i in daten: + zahlen.append(int(i.text)) +a = 1 +while a != 7: + Lottozahlen['Z' + str(a)] = zahlen[a - 1] + a = a + 1 +Spiel77 = '' +Super6 = '' +zahlen77 = [] +daten = soup.find_all('div', class_="winning-numbers__number--additional") +for i in daten: + zahlen77.append(int(i.text)) +spiel77 = zahlen77[0:7] +super6 = zahlen77[-6:] +for i in spiel77: + Spiel77 = Spiel77 + str(i) +for i in super6: + Super6 = Super6 + str(i) + +daten = soup.find_all('h2', class_="strong hidden-xs") +for i in daten: + date = i.text + date = date.replace(' ', '') + date = date.replace('\n', '') + +start = (date.find('dem')) + 4 +ende = (date.find('(Alle')) + +Lottozahlen['Superzahl'] = zahlen[6] +Lottozahlen['Spiel77'] = Spiel77 +Lottozahlen['Super6'] = Super6 +Lottozahlen['Datum'] = date[start:ende] + + + + +try: + cursor.execute("""CREATE TABLE euro ( + datum Text, z1 INTEGER, z2 INTEGER, z3 INTEGER, z4 INTEGER, z5 INTEGER, sz1 INTEGER, sz2 INTEGER )""") +except: + None + +data = ZahlenEuro +sql = "INSERT INTO `euro`(`datum`, `z1`, `z2`, `z3`, `z4`, `z5`, `sz1`, `sz2`) VALUES" \ + " ('" + str(data['Datum']) + "','" + str(data['Z1']) + "','" + str(data['Z2']) + "','" + str(data['Z3']) + \ + "','" + str(data['Z4']) + "','" + str(data['Z5']) + "','" + str(data['Eurozahl1']) + "','" + str( + data['Eurozahl2']) + "')" +sql_q = "SELECT * FROM euro WHERE datum like '%" + data['Datum'] + "%'" +resp = cursor.execute(sql_q) +if resp == 0: + cursor.execute(sql) +data=Lottozahlen + +if "Samstag," in date: + try: + cursor.execute("""CREATE TABLE samstag ( + datum Text, z1 INTEGER, z2 INTEGER, z3 INTEGER, z4 INTEGER, z5 INTEGER, z6 INTEGER, sz INTEGER, super6 INTEGER, spiel77 INTEGER)""") + except: + None + sql = "INSERT INTO `samstag`(`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 samstag WHERE datum like '%" + data['Datum'] + "%'" + resp = cursor.execute(sql_q) + if resp == 0: + cursor.execute(sql) + connection.commit() + +if "Mittwoch," in date: + try: + cursor.execute("""CREATE TABLE mittwoch ( + datum Text, z1 INTEGER, z2 INTEGER, z3 INTEGER, z4 INTEGER, z5 INTEGER, z6 INTEGER, sz INTEGER, super6 INTEGER, spiel77 INTEGER)""") + except: + None + + sql = "INSERT INTO `mittwoch`(`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 mittwoch WHERE datum like '%" + data['Datum'] + "%'" + resp = cursor.execute(sql_q) + if resp == 0: + cursor.execute(sql) + connection.commit() + + try: + cursor.execute("""CREATE TABLE 6aus49 ( + datum Text, z1 INTEGER, z2 INTEGER, z3 INTEGER, z4 INTEGER, z5 INTEGER, z6 INTEGER, sz INTEGER, super6 INTEGER, spiel77 INTEGER)""") + except: + None + +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() + +tag=int((time.strftime("%w"))) +if tag != 5: + print(Lottozahlen) +elif tag == 7: + print(ZahlenEuro) +print(ZahlenEuro) \ No newline at end of file diff --git a/Pool_old/Lotto2SQL_V2.py b/Pool_old/Lotto2SQL_V2.py new file mode 100644 index 0000000..1e7ff8d --- /dev/null +++ b/Pool_old/Lotto2SQL_V2.py @@ -0,0 +1,116 @@ +import pymysql +import bs4 as bs +import requests +import time + +requests.packages.urllib3.disable_warnings() +sauce = requests.get('https://www.lotto-hessen.de/lotto6aus49/gewinnzahlen-quoten/gewinnzahlen', verify=False) +soup = bs.BeautifulSoup(sauce.text, 'lxml') +print(soup) +Lottozahlen = {'Datum': '', 'Z1': '', 'Z2': '', 'Z3': '', 'Z4': '', 'Z5': '', 'Z6': '', 'Superzahl': '', + 'Spiel77': '', 'Super6': ''} +a = 0 +daten = soup.find_all('span') +zahlen = [] +for i in daten: + if a >= 1 and a < 7: + Lottozahlen['Z' + str(a)] = i.text + if a == 7: + Lottozahlen['Superzahl'] = i.text + a = a + 1 + if i.text == 'Tag': + a = 1 +for i in daten: + if a > 0 and a < 8: + Lottozahlen['Spiel77'] = Lottozahlen['Spiel77']+i.text + if a > 7 and a < 14: + Lottozahlen['Super6'] = Lottozahlen['Super6']+i.text + a = a +1 + if i.text == 'Superzahl': + a = 1 +daten = soup.find_all('h2', class_="h4") +for i in daten: + Lottozahlen['Datum']=i.text +a=1 +while a < 7: + Lottozahlen['Z' + str(a)] = int(Lottozahlen['Z'+str(a)]) + a = a + 1 +Lottozahlen['Superzahl'] = int(Lottozahlen['Superzahl']) +Lottozahlen['Spiel77'] = int(Lottozahlen['Spiel77']) +Lottozahlen['Super6'] = int(Lottozahlen['Super6']) +datum = Lottozahlen['Datum'] +start = datum.find(', ') +Lottozahlen['Datum'] = datum[start+2:] +print(Lottozahlen) +requests.packages.urllib3.disable_warnings() +sauce = requests.get('https://www.lotto-hessen.de/eurojackpot/gewinnzahlen-quoten/gewinnzahlen?gbn=5', verify=False) +soup = bs.BeautifulSoup(sauce.text, 'lxml') +ZahlenEuro = {'Datum': '', 'Z1': '', 'Z2': '', 'Z3': '', 'Z4': '', 'Z5': '', 'Eurozahl1': '', 'Eurozahl2': ''} +daten = soup.find_all('span') +for i in daten: + if i.text =='Tag': + a = -1 + a = a + 1 + if a >= 1 and a < 6: + ZahlenEuro['Z'+str(a)] = int(i.text) + if a == 6: + ZahlenEuro['Eurozahl1'] = int(i.text) + if a == 7: + ZahlenEuro['Eurozahl2'] = int(i.text) +daten = soup.find_all('h2', class_="h4") +for i in daten: + ZahlenEuro['Datum'] = i.text +datums = ZahlenEuro['Datum'] +start = datums.find(', ') +ZahlenEuro['Datum'] = datums[start+2:] +print(ZahlenEuro) + +connection = pymysql.connect(db="hubobel", + user="hubobel", + passwd="polier2003", + host='10.0.1.123',charset='utf8') +cursor = connection.cursor() + +data = ZahlenEuro +sql = "INSERT INTO `euro`(`datum`, `z1`, `z2`, `z3`, `z4`, `z5`, `sz1`, `sz2`) VALUES" \ + " ('" + str(data['Datum']) + "','" + str(data['Z1']) + "','" + str(data['Z2']) + "','" + str(data['Z3']) + \ + "','" + str(data['Z4']) + "','" + str(data['Z5']) + "','" + str(data['Eurozahl1']) + "','" + str( + data['Eurozahl2']) + "')" +sql_q = "SELECT * FROM euro WHERE datum like '%" + data['Datum'] + "%'" +resp = cursor.execute(sql_q) +if resp == 0: + cursor.execute(sql) + +data = Lottozahlen +if 'Samstag,' in datum: + sql = "INSERT INTO `samstag`(`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 samstag WHERE datum like '%" + data['Datum'] + "%'" + resp = cursor.execute(sql_q) + if resp == 0: + cursor.execute(sql) + +if 'Mittwoch,' in datum: + sql = "INSERT INTO `mittwoch`(`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 mittwoch WHERE datum like '%" + data['Datum'] + "%'" + resp = cursor.execute(sql_q) + if resp == 0: + cursor.execute(sql) + +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() \ No newline at end of file diff --git a/Pool_old/lotto24.py b/Pool_old/lotto24.py new file mode 100644 index 0000000..923e343 --- /dev/null +++ b/Pool_old/lotto24.py @@ -0,0 +1,70 @@ +import bs4 as bs +import requests +import time + +requests.packages.urllib3.disable_warnings() +sauce=requests.get('https://www.eurojackpot.org/gewinnzahlen/',verify=False) +soup = bs.BeautifulSoup(sauce.text,'lxml') + +print(soup) +zahlen=[] +ergebniss=[] +ZahlenEuro = {'Datum': '', 'Z1': '', 'Z2': '', 'Z3': '', 'Z4': '', 'Z5': '', 'Eurozahl1': '', 'Eurozahl2': ''} +a=1 +datum= soup.find_all('div') +print(datum) +tag=[] +for i in datum: + tag.append(i.text) +for li in soup.find_all('li'): + zahlen.append(li.text) +for i in zahlen[0:7]: + ergebniss.append(int(i)) +ergebniss.append(tag[1]) +while a!=6: + ZahlenEuro['Z'+str(a)]=ergebniss[a-1] + a=a+1 +ZahlenEuro['Datum']=ergebniss[7] +ZahlenEuro['Eurozahl1']=ergebniss[5] +ZahlenEuro['Eurozahl2']=ergebniss[6] + +requests.packages.urllib3.disable_warnings() +sauce=requests.get('https://www.lotto24.de/webshop/product/lottonormal/result',verify=False) +soup = bs.BeautifulSoup(sauce.text,'lxml') + +#print(soup.prettify()) +Lottozahlen = {'Datum': '', 'Z1': '', 'Z2': '', 'Z3': '', 'Z4': '', 'Z5': '', 'Z6': '', 'Superzahl': '', + 'Spiel77': '', 'Super6': ''} +daten=soup.find_all('div',class_="winning-numbers__number") +zahlen=[] +for i in daten: + zahlen.append(int(i.text)) +a=1 +while a!=7: + Lottozahlen['Z'+str(a)]=zahlen[a-1] + a=a+1 +Spiel77='' +Super6='' +zahlen77=[] +daten=soup.find_all('div',class_="winning-numbers__number--additional") +for i in daten: + zahlen77.append(int(i.text)) +spiel77=zahlen77[0:7] +super6=zahlen77[-6:] +for i in spiel77: + Spiel77=Spiel77+str(i) +for i in super6: + Super6=Super6+str(i) + +daten=soup.find_all('h2',class_="strong hidden-xs") +for i in daten: + date=i.text + date=date.replace(' ','') + date = date.replace('\n', '') + +Lottozahlen['Superzahl']=zahlen[6] +Lottozahlen['Spiel77']=Spiel77 +Lottozahlen['Super6']=Super6 +Lottozahlen['Datum']=date +print(Lottozahlen) +print(ZahlenEuro) \ No newline at end of file