Eurojackpot korrigiert und auf lotto24.de umgestellt

This commit is contained in:
hubobel 2020-05-23 14:39:49 +02:00
parent 80d7a2ac9d
commit 95bc51dc34
50 changed files with 271 additions and 47 deletions

View file

@ -5,6 +5,7 @@
<w>farbe</w>
<w>fyeg</w>
<w>gibt</w>
<w>gibts</w>
<w>nicht</w>
</words>
</dictionary>

View file

@ -3,12 +3,16 @@
import requests
import telebot
import datetime
import json
from datetime import datetime as DateTime
hour = datetime.datetime.now().hour
TOKEN='680737840:AAEaa7Vxl_kZz_LWS1_S-lH6Eda7HXqu6Y4'
ChatID='322673713'
tb = telebot.TeleBot(TOKEN)
ort = '/home/carsten/Scripts/'
ort = ''
Zeitstempel = DateTime.now().strftime('%Y_%m_%d_%H_%M_%S')
antwort=''
def mzwi():
@ -16,6 +20,8 @@ def mzwi():
resp_zitat = requests.get(url_zitat)
data_zitat = resp_zitat.json()
telegramm = 'Mainz - Wiesbaden\n'
with open(ort + str(Zeitstempel) + '_data.txt', 'w') as outfile:
json.dump(data_zitat, outfile)
for i in data_zitat['departures']:
if i['train'] == "S 8":
if i['destination'] == 'Wiesbaden Hbf':
@ -44,6 +50,8 @@ def wimz():
resp_zitat = requests.get(url_zitat)
data_zitat = resp_zitat.json()
telegramm = 'Wiesbaden - Mainz\n'
with open(ort + str(Zeitstempel) + '_data.txt', 'w') as outfile:
json.dump(data_zitat, outfile)
for i in data_zitat['departures']:
if i['train'] == "S 8":
if i['destination'] == 'Offenbach(Main)Ost':
@ -75,6 +83,8 @@ def mzaz():
resp_zitat = requests.get(url_zitat)
data_zitat = resp_zitat.json()
telegramm = 'Mainz - Alzey\n'
with open(ort + str(Zeitstempel) + '_data.txt', 'w') as outfile:
json.dump(data_zitat, outfile)
for i in data_zitat['departures']:
if i['train'] == "RE 13":
if i['delayDeparture'] != None:
@ -105,6 +115,8 @@ def azmz():
resp_zitat = requests.get(url_zitat)
data_zitat = resp_zitat.json()
telegramm = 'Alzey - Mainz\n'
with open(ort + str(Zeitstempel) + '_data.txt', 'w') as outfile:
json.dump(data_zitat, outfile)
for i in data_zitat['departures']:
# print(i)
if i['train'] == "RE 13":

BIN
Bild Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 388 KiB

117
Chuck2SQL.py Normal file
View file

@ -0,0 +1,117 @@
# -*- coding: UTF8 -*-
import requests
import datetime
import pymysql
class BotHandler:
def __init__(self, token):
self.token = token
self.api_url = "https://api.telegram.org/bot{}/".format(token)
#url = "https://api.telegram.org/bot<token>/"
def get_updates(self, offset=0, timeout=30):
method = 'getUpdates'
params = {'timeout': timeout, 'offset': offset}
resp = requests.get(self.api_url + method, params)
result_json = resp.json()['result']
return result_json
def send_message(self, chat_id, text):
params = {'chat_id': chat_id, 'text': text, 'parse_mode': 'HTML'}
method = 'sendMessage'
resp = requests.post(self.api_url + method, params)
return resp
def get_first_update(self):
get_result = self.get_updates()
if len(get_result) > 0:
last_update = get_result[0]
else:
last_update = None
return last_update
token = '1030619458:AAGTrWO2-m38ViL0y2R8XaV0P1gg8kHxj3o' #Token of your bot
magnito_bot = BotHandler(token) #Your bot's name
def main():
new_offset = 0
print('hi, now launching...')
while True:
all_updates=magnito_bot.get_updates(new_offset)
if len(all_updates) > 0:
for current_update in all_updates:
print(current_update)
first_update_id = current_update['update_id']
if 'text' not in current_update['message']:
first_chat_text='New member'
else:
first_chat_text = current_update['message']['text']
first_chat_id = current_update['message']['chat']['id']
if 'first_name' in current_update['message']:
first_chat_name = current_update['message']['chat']['first_name']
elif 'new_chat_member' in current_update['message']:
first_chat_name = current_update['message']['new_chat_member']['username']
elif 'from' in current_update['message']:
first_chat_name = current_update['message']['from']['first_name']
else:
first_chat_name = "unknown"
signal = first_chat_text[0:5]
if signal == '/0815':
magnito_bot.send_message(first_chat_id, 'Ich lausche deinem Befehl ' + first_chat_name)
new_offset = first_update_id + 1
connection = pymysql.connect(db="hubobel",
user="hubobel",
passwd="polier2003",
host='10.0.1.59', charset='utf8')
cursor = connection.cursor()
sql = "SELECT * FROM facts ORDER BY nr DESC"
resp = cursor.execute(sql)
x = int(resp)
magnito_bot.send_message(first_chat_id, 'Es gibt derzeit ' + str(x) + ' Facts')
fact = first_chat_text[6:]
sql = "INSERT INTO `facts`(`nr`, `fact`) VALUES ('" + str(x+1) + "','" + fact + "')"
sql_q = "SELECT * FROM facts WHERE fact like '%" + fact + "%'"
resp = cursor.execute(sql_q)
if resp == 0:
try:
resp = cursor.execute(sql)
magnito_bot.send_message(first_chat_id, 'Ich habe diesen Fact an SQL übertragen: ' + fact)
except:
magnito_bot.send_message(first_chat_id, 'Ich hatte ein Problem, den Fact an SQL zu übermitteln!')
else:
magnito_bot.send_message(first_chat_id, 'Den Fact "' + fact+ ' "gibt es schon in meiner Database!')
connection.commit()
cursor.close()
connection.close()
else:
if first_chat_text == 'Hi':
magnito_bot.send_message(first_chat_id, 'Morning ' + first_chat_name)
new_offset = first_update_id + 1
elif first_chat_text == 'Wer bin ich':
magnito_bot.send_message(first_chat_id, 'Du bist der Größte '+ signal)
new_offset = first_update_id + 1
else:
magnito_bot.send_message(first_chat_id, 'How are you doing '+first_chat_name)
new_offset = first_update_id + 1
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
exit()

32
Euro2SQL.py Normal file
View file

@ -0,0 +1,32 @@
import bs4 as bs
import requests
requests.packages.urllib3.disable_warnings()
sauce = requests.get('https://www.lotto24.de/webshop/product/eurojackpot/result', verify=False)
soup = bs.BeautifulSoup(sauce.text, 'lxml')
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
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'))
ZahlenEuro['Datum'] = date[start:ende]
print(ZahlenEuro)

View file

@ -16,17 +16,18 @@ except:
None
sql = "SELECT * FROM Filosofie ORDER BY Nr DESC"
resp = cursor.execute(sql)
AnzahlStart=resp
db=[]
ergebniss=''
AnzahlStart = resp
db = []
ergebniss = ''
requests.packages.urllib3.disable_warnings()
sauce = requests.get('https://www.swr3.de/wraps/fun/filosofie/neu.php?id=1151', verify=False)
sauce = requests.get('https://www.swr3.de/wraps/fun/filosofie/neu.php?id=1300', verify=False)
soup = bs.BeautifulSoup(sauce.text, 'lxml')
for i in soup.find_all('div'):
ergebniss=ergebniss+str(i)
start=(ergebniss.find('href="/wraps/fun/filosofie/neu.php?id=1152&amp;cf=42"> weiter &gt; </a>   <a class="linkred" href='))
anzahl=int(ergebniss[start+131:start+135])
start=int(resp)+1+110
ergebniss = ergebniss+str(i)
start = (ergebniss.find('href="/wraps/fun/filosofie/neu.php?id=1152&amp;cf=42"> weiter &gt; </a>   <a class="linkred" href='))
print(ergebniss)
anzahl = int(ergebniss[start+131:start+135])
start = int(resp)+1+110
while start <= anzahl:
url='https://www.swr3.de/wraps/fun/filosofie/neu.php?id='+str(start)

View file

@ -1,6 +1,7 @@
import pymysql
import bs4 as bs
import requests
import time
connection = pymysql.connect(db="hubobel",
user="hubobel",
@ -8,36 +9,38 @@ connection = pymysql.connect(db="hubobel",
host='10.0.1.59',charset='utf8')
cursor = connection.cursor()
#todo eurojackpot wieder fixen
requests.packages.urllib3.disable_warnings()
sauce = requests.get('https://www.eurojackpot.org/gewinnzahlen/', verify=False)
sauce = requests.get('https://www.lotto24.de/webshop/product/eurojackpot/result', verify=False)
soup = bs.BeautifulSoup(sauce.text, 'lxml')
ZahlenEuro = {'Datum': '', 'Z1': '', 'Z2': '', 'Z3': '', 'Z4': '', 'Z5': '', 'Eurozahl1': '', 'Eurozahl2': ''}
a = 1
datum = soup.find_all('li')
for i in datum:
i=str(i)
i = i.replace('<li>' , '').replace('</li>' , '').replace('<li class="extra">' , '')
if a <= 7:
if a<6:
ZahlenEuro['Z'+str(a)]=i
if a ==6:
ZahlenEuro['Eurozahl1']=i
if a ==7:
ZahlenEuro['Eurozahl2']=i
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
sauce=(soup.find_all('div', class_ ='calendar'))
date=(soup.select_one('input[id=calendar]')['value'])
ZahlenEuro['Datum']=date
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'))
ZahlenEuro['Datum'] = date[start:ende]
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")
@ -75,15 +78,15 @@ Lottozahlen['Spiel77'] = Spiel77
Lottozahlen['Super6'] = Super6
Lottozahlen['Datum'] = date[start:ende]
#print(ZahlenEuro)
print(Lottozahlen)
print(date)
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']) + \
@ -145,4 +148,11 @@ if resp == 0:
connection.commit()
cursor.close()
connection.close()
connection.close()
tag=int((time.strftime("%w")))
if tag != 5:
print(Lottozahlen)
elif tag == 7:
print(ZahlenEuro)
print(ZahlenEuro)

11
Test4_Pfad.py Normal file
View file

@ -0,0 +1,11 @@
import os
import time
path = "testa"
monat = (time.strftime("%m"))
jahr = (time.strftime("%Y"))
path = path + '/' + jahr + '/' + monat
if os.path.exists(path) == False:
print('gibts nicht')
os.makedirs(path)

27
Timelapse.py Normal file
View file

@ -0,0 +1,27 @@
import urllib.request
import requests
from datetime import datetime as DateTime
import time
import os
path = os.getcwd() + "/cameras/wz"
print(path)
monat = (time.strftime("%m"))
jahr = (time.strftime("%Y"))
tag = (time.strftime("%d"))
path = path + '/' + jahr + '/' + monat + '/' + tag
if not os.path.exists(path):
print('gibts nicht')
os.makedirs(path)
while True:
url_WZ = 'http://10.0.1.241/api.cgi?cmd=GetMdState&user=admin&password=polier2003'
resp_WZ = requests.get(url_WZ)
data_WZ = resp_WZ.json()
motion_wz = data_WZ[0]['value']['state']
if motion_wz == 1:
Zeit = DateTime.now().strftime('%H_%M_%S')
url = 'http://10.0.1.241/cgi-bin/api.cgi?cmd=Snap&channel=0&rs=wuuPhkmUCeI9WG7C&user=admin&password=polier2003'
urllib.request.urlretrieve(url, path + '/Bild'+Zeit+'.jpg')
time.sleep(2)

Binary file not shown.

After

Width:  |  Height:  |  Size: 397 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 378 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 350 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 352 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 340 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 345 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 341 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 359 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 357 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 350 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 385 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 349 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 317 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 336 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 334 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 338 KiB

1
data.txt Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

43
test.py
View file

@ -1,6 +1,7 @@
import pymysql
import bs4 as bs
import requests
import time
connection = pymysql.connect(db="hubobel",
user="hubobel",
@ -14,26 +15,36 @@ requests.packages.urllib3.disable_warnings()
sauce = requests.get('https://www.eurojackpot.org/gewinnzahlen/', verify=False)
soup = bs.BeautifulSoup(sauce.text, 'lxml')
#print(soup)
#print(soup)
print(soup)
# zahlen = []
# ergebniss = []
ZahlenEuro = {'Datum': '', 'Z1': '', 'Z2': '', 'Z3': '', 'Z4': '', 'Z5': '', 'Eurozahl1': '', 'Eurozahl2': ''}
a = 1
datum = soup.find_all('li')
for i in datum:
i=str(i)
i = i.replace('<li>' , '').replace('</li>' , '').replace('<li class="extra">' , '')
if a <= 7:
if a<6:
ZahlenEuro['Z'+str(a)]=i
if a ==6:
ZahlenEuro['Eurozahl1']=i
if a ==7:
ZahlenEuro['Eurozahl2']=i
a +=1
#print(soup)
for i in datum:
j = str(i)
print(j)
if j[:4] == '<li>':
if j[:5] != '<li><':
print(i)
for i in datum:
j = str(i)
#print(j)
if j[:17] == '<li class="extra"':
print(j[18:19])
print(ZahlenEuro)
sauce=(soup.find_all('div', class_ ='calendar'))
date=(soup.select_one('input[id=calendar]')['value'])
ZahlenEuro['Datum']=date
print(ZahlenEuro)
print(sauce)
#date=(soup.select_one('input[id=calendar]')['value'])
#ZahlenEuro['Datum']=date
tag=int((time.strftime("%w")))
if tag == 6:
datum = (time.strftime("%d.%m.%Y"))
print(datum)