diff --git a/.idea/HubobelsPython.iml b/.idea/HubobelsPython.iml index 6711606..f4e5d15 100644 --- a/.idea/HubobelsPython.iml +++ b/.idea/HubobelsPython.iml @@ -2,7 +2,7 @@ - + diff --git a/.idea/dictionaries/hubobel.xml b/.idea/dictionaries/hubobel.xml new file mode 100644 index 0000000..80d46dd --- /dev/null +++ b/.idea/dictionaries/hubobel.xml @@ -0,0 +1,11 @@ + + + + diese + farbe + fyeg + gibt + nicht + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 3a3f450..ab67a79 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,7 @@ + + \ No newline at end of file diff --git a/Dashbutton.py b/Dashbutton.py index 6bbac80..51e52f7 100644 --- a/Dashbutton.py +++ b/Dashbutton.py @@ -3,6 +3,7 @@ import datetime import logging import urllib2 +#import scapy # Constants timespan_threshhold = 3 diff --git a/Frank.py b/Frank.py new file mode 100644 index 0000000..e8b41a3 --- /dev/null +++ b/Frank.py @@ -0,0 +1,13 @@ +import base64 +pool = {'cm90': 'MjAuMDAwMQ==', 'c2Nod2Fyeg==': 'MzAuMTIzNA==', 'Z29sZA==': 'NDAuMTIzNA=='} +while True: + antwort = input('Farbe:').lower() + code = (base64.b64encode(str.encode(antwort))).decode('utf-8') + if code in pool: + print(base64.b64decode((pool[code])).decode('utf-8')) + elif antwort[0] == '#': + print(base64.b64encode(str.encode(antwort[1:])).decode('utf-8')) + elif antwort == 'exit': + break + else: + print('Diese Farbe gibt es nicht') \ No newline at end of file diff --git a/Hue.py b/Hue.py new file mode 100644 index 0000000..38b872a --- /dev/null +++ b/Hue.py @@ -0,0 +1,42 @@ +from qhue import Bridge +import requests +import paho.mqtt.client as mqtt +import time + + +client = mqtt.Client() +client.username_pw_set(username="hubobel",password="polier2003") + + +while True: + b = Bridge("10.0.1.19", "GxPN8lQmEvY5LXwtGRfKM5vwXegY9Yv10N0j2kxr") + url=b.url + response = requests.get(url) + data_response = response.json() + #print('Elemente in Bridge angemeldet: ',len(data_response)) + + for i in data_response['sensors']: + try: + if data_response['sensors'][i]['productname'] == 'Hue dimmer switch': + #print(data_response['sensors'][i]) + + states={'1002':True, '2002':'Dim up', '3002':'Dim down', '4002':False, '1000':True, '4000':False} + + for a in states: + if str(a) == str(data_response['sensors'][i]['state']['buttonevent']): + #print(data_response['sensors'][i]['name'], ' buttonstate: ',states[a]) + pfad="Test/"+data_response['sensors'][i]['name'] + pfad=pfad.replace(' ','_') + #print(pfad) + try: + client.connect("10.0.1.59", 1884, 60) + client.publish(pfad, states[a]) + print('puplished') + client.disconnect() + except: + print('error') + time.sleep(1) + except: + None + time.sleep(5) +#client.disconnect() diff --git a/Lotto2SQL.py b/Lotto2SQL.py index 684ecf1..e9e7ff3 100644 --- a/Lotto2SQL.py +++ b/Lotto2SQL.py @@ -1,7 +1,6 @@ -import requests import pymysql -import time - +import bs4 as bs +import requests connection = pymysql.connect(db="hubobel", user="hubobel", @@ -9,67 +8,141 @@ connection = pymysql.connect(db="hubobel", host='10.0.1.59',charset='utf8') cursor = connection.cursor() -wtag = time.strftime('%w') +#todo eurojackpot wieder fixen -if wtag == 3: - 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 - url_zitat = 'http://api.hubobel.de/lotto/Mittwoch' - resp_zitat = requests.get(url_zitat) - data_zitat = resp_zitat.json() - data=data_zitat[1] - 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() +requests.packages.urllib3.disable_warnings() +sauce = requests.get('https://www.eurojackpot.org/gewinnzahlen/', verify=False) +soup = bs.BeautifulSoup(sauce.text, 'lxml') -if wtag == 6: +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('
  • ' , '').replace('
  • ' , '').replace('
  • ' , '') + 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 + +sauce=(soup.find_all('div', class_ ='calendar')) +date=(soup.select_one('input[id=calendar]')['value']) +ZahlenEuro['Datum']=date + +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', '') + +start = (date.find('dem')) + 4 +ende = (date.find('(Alle')) + +Lottozahlen['Superzahl'] = zahlen[6] +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']) + \ + "','" + 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 - url_zitat = 'http://api.hubobel.de/lotto/Samstag' - resp_zitat = requests.get(url_zitat) - data_zitat = resp_zitat.json() - data=data_zitat[1] 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'])+"')" + " ('" + 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 wtag == 5: +if "Mittwoch," in date: try: - cursor.execute("""CREATE TABLE euro ( - datum Text, z1 INTEGER, z2 INTEGER, z3 INTEGER, z4 INTEGER, z5 INTEGER, sz1 INTEGER, sz2 INTEGER )""") + 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 - url_zitat = 'http://api.hubobel.de/lotto/Euro' - resp_zitat = requests.get(url_zitat) - data_zitat = resp_zitat.json() - data=data_zitat[1] - 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['Superzahl1'])+"','"+str(data['Superzahl2'])+"')" - sql_q = "SELECT * FROM euro WHERE datum like '%" + data['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) - 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() +connection.close() \ No newline at end of file diff --git a/Pulsecounter.py b/Pulsecounter.py new file mode 100644 index 0000000..246ad5b --- /dev/null +++ b/Pulsecounter.py @@ -0,0 +1,9 @@ +import requests + +url = 'http://10.0.1.103/?json:' +response = requests.get(url) +data_response = response.json() +a=[1,2,3,4,5,6] +for i in a: + print(data_response['vars'][i]['value'], data_response['vars'][i]['unit']) + diff --git a/REST_APIv2.py b/REST_APIv2.py index 313fe13..6283162 100644 --- a/REST_APIv2.py +++ b/REST_APIv2.py @@ -1,92 +1,12 @@ import random from flask import Flask, jsonify,make_response +from flask import request import pymysql import bs4 as bs -import urllib.request +import requests as req app = Flask(__name__) -def Lotto(): - sauce = urllib.request.urlopen('http://www.lottotip-check.de').read() - soup = bs.BeautifulSoup(sauce, 'html.parser') - - # print(soup.prettify()) - table = soup.find_all('table') - row = [] - ZahlenAll = [] - ZahlenMittwoch = {'Datum': '', 'Z1': '', 'Z2': '', 'Z3': '', 'Z4': '', 'Z5': '', 'Z6': '', 'Superzahl': '', - 'Spiel77': '', 'Super6': ''} - ZahlenSamstag = {'Datum': '', 'Z1': '', 'Z2': '', 'Z3': '', 'Z4': '', 'Z5': '', 'Z6': '', 'Superzahl': '', - 'Spiel77': '', 'Super6': ''} - ZahlenEuro = {'Datum': '', 'Z1': '', 'Z2': '', 'Z3': '', 'Z4': '', 'Z5': '', 'Superzahl1': '', 'Superzahl2': ''} - for i in table: - table_rows = i.find_all('tr') - for tr in table_rows: - # print(tr) - td = tr.find_all('td') - if td != []: - row = [i.text for i in td] - # print(row) - th = tr.find_all('th') - sz = [i.text for i in th] - # print(len(sz)) - if len(sz) == 5: - row.append(str(sz[2])) - row.append(str(sz[3])) - date = 'Ziehung vom: ' + str(sz[0]) - sz = str(sz[1]) - row.append(sz) - row.insert(0, date) - ZahlenAll.extend(row) - a = 0 - while a <= 5: - a = a + 1 - ZahlenMittwoch['Z' + str(a)] = int(ZahlenAll[a]) - ZahlenMittwoch['Datum'] = ZahlenAll[0] - ZahlenMittwoch['Superzahl'] = int(ZahlenAll[9]) - ZahlenMittwoch['Super6'] = int(ZahlenAll[8]) - ZahlenMittwoch['Spiel77'] = int(ZahlenAll[7]) - print(ZahlenMittwoch) - a = 0 - while a <= 5: - a = a + 1 - ZahlenSamstag['Z' + str(a)] = int(ZahlenAll[a + 18]) - ZahlenSamstag['Datum'] = ZahlenAll[18] - ZahlenSamstag['Superzahl'] = int(ZahlenAll[27]) - ZahlenSamstag['Super6'] = int(ZahlenAll[26]) - ZahlenSamstag['Spiel77'] = int(ZahlenAll[25]) - print(ZahlenSamstag) - - a = 0 - while a <= 4: - a = a + 1 - ZahlenEuro['Z' + str(a)] = int(ZahlenAll[a + 10]) - ZahlenEuro['Datum'] = ZahlenAll[10] - ZahlenEuro['Superzahl2'] = int(ZahlenAll[17]) - ZahlenEuro['Superzahl1'] = int(ZahlenAll[16]) - print(ZahlenEuro) - return ZahlenMittwoch,ZahlenEuro,ZahlenSamstag - -@app.route('/lotto', methods=['GET']) -def get_lotto(): - Mit,EUR,Sam=Lotto() - return jsonify('alle Angaben ohne Gewaehr:',Mit,EUR,Sam) - -@app.route('/lotto/Samstag', methods=['GET']) -def get_lottoSam(): - Mit,EUR,Sam=Lotto() - return jsonify('alle Angaben ohne Gewaehr:',Sam) - -@app.route('/lotto/Mittwoch', methods=['GET']) -def get_lottoMit(): - Mit,EUR,Sam=Lotto() - return jsonify('alle Angaben ohne Gewaehr:',Mit) - -@app.route('/lotto/Euro', methods=['GET']) -def get_lottoEur(): - Mit,EUR,Sam=Lotto() - return jsonify('alle Angaben ohne Gewaehr:',EUR) - def Update(): connection = pymysql.connect(db="hubobel", user="hubobel", @@ -101,22 +21,204 @@ def Update(): connection.close() a=len(fact) return fact,a +def Lotto(): + + connection = pymysql.connect(db="hubobel", + user="hubobel", + passwd="polier2003", + host='10.0.1.59', charset='utf8') + cursor = connection.cursor() + sql = "SELECT * FROM mittwoch ORDER BY id DESC" + resp = cursor.execute(sql) + x = int(resp) + sql_q = "SELECT * FROM mittwoch WHERE id like '" + str(x) + "'" + cursor.execute(sql_q) + resp = cursor.fetchall() + resp = (resp[0][1:]) + ZahlenMittwoch = {'Datum': '', 'Z1': '', 'Z2': '', 'Z3': '', 'Z4': '', 'Z5': '', 'Z6': '', 'Superzahl': '', + 'Spiel77': '', 'Super6': ''} + a = 1 + while a != 7: + ZahlenMittwoch['Z' + str(a)] = resp[a] + a = a + 1 + ZahlenMittwoch['Datum'] = resp[0] + ZahlenMittwoch['Superzahl'] = resp[7] + ZahlenMittwoch['Spiel77'] = resp[9] + ZahlenMittwoch['Super6'] = resp[8] + + cursor = connection.cursor() + sql = "SELECT * FROM samstag ORDER BY id DESC" + resp = cursor.execute(sql) + x = int(resp) + sql_q = "SELECT * FROM samstag WHERE id like '" + str(x) + "'" + cursor.execute(sql_q) + resp = cursor.fetchall() + resp = resp[0][1:] + ZahlenSamstag = {'Datum': '', 'Z1': '', 'Z2': '', 'Z3': '', 'Z4': '', 'Z5': '', 'Z6': '', 'Superzahl': '', + 'Spiel77': '', 'Super6': ''} + a = 1 + while a != 7: + ZahlenSamstag['Z' + str(a)] = resp[a] + a = a + 1 + ZahlenSamstag['Datum'] = resp[0] + ZahlenSamstag['Superzahl'] = resp[7] + ZahlenSamstag['Spiel77'] = resp[9] + ZahlenSamstag['Super6'] = resp[8] + + cursor = connection.cursor() + sql = "SELECT * FROM euro ORDER BY id DESC" + resp = cursor.execute(sql) + x = int(resp) + sql_q = "SELECT * FROM euro WHERE id like '" + str(x) + "'" + cursor.execute(sql_q) + resp = cursor.fetchall() + resp = resp[0][1:] + ZahlenEuro = {'Datum': '', 'Z1': '', 'Z2': '', 'Z3': '', 'Z4': '', 'Z5': '', 'Eurozahl1': '', 'Eurozahl2': ''} + a = 1 + while a != 6: + ZahlenEuro['Z' + str(a)] = resp[a] + a = a + 1 + ZahlenEuro['Datum'] = resp[0] + ZahlenEuro['Eurozahl1'] = resp[6] + ZahlenEuro['Eurozahl2'] = resp[7] + connection.commit() + cursor.close() + connection.close() + return ZahlenMittwoch,ZahlenEuro,ZahlenSamstag +def Lottoaktuell(): + req.packages.urllib3.disable_warnings() + sauce = req.get('https://www.eurojackpot.org/gewinnzahlen/', verify=False) + soup = bs.BeautifulSoup(sauce.text, 'lxml') + + zahlen = [] + ergebniss = [] + ZahlenEuro = {'Datum': '', 'Z1': '', 'Z2': '', 'Z3': '', 'Z4': '', 'Z5': '', 'Eurozahl1': '', 'Eurozahl2': ''} + a = 1 + datum = soup.find_all('time') + 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 + + + + ende = (ergebniss[7].find('- Freitag')) + Datum=ergebniss[7] + ZahlenEuro['Datum'] = Datum[:ende-1] + ZahlenEuro['Eurozahl1'] = ergebniss[5] + ZahlenEuro['Eurozahl2'] = ergebniss[6] + + req.packages.urllib3.disable_warnings() + sauce = req.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', '') + + start = (date.find('dem')) + 4 + ende = (date.find('(Alle')) + + Lottozahlen['Superzahl'] = zahlen[6] + Lottozahlen['Spiel77'] = Spiel77 + Lottozahlen['Super6'] = Super6 + Lottozahlen['Datum'] = date[start:ende] + + return Lottozahlen,ZahlenEuro + +@app.route('/lotto', methods=['GET']) +def get_lotto(): + Mit,EUR,Sam=Lotto() + return jsonify('Hinweis: Alle Angaben ohne Gewaehr auf Richtigkeit:',Mit,EUR,Sam) + +@app.route('/lotto/Samstag', methods=['GET']) +def get_lottoSam(): + Mit,EUR,Sam=Lotto() + return jsonify('Hinweis: Alle Angaben ohne Gewaehr auf Richtigkeit:',Sam) + +@app.route('/lotto/Mittwoch', methods=['GET']) +def get_lottoMit(): + Mit,EUR,Sam=Lotto() + return jsonify('Hinweis: Alle Angaben ohne Gewaehr auf Richtigkeit:',Mit) + +@app.route('/lotto/Euro', methods=['GET']) +def get_lottoEur(): + Mit,EUR,Sam=Lotto() + return jsonify('Hinweis: Alle Angaben ohne Gewaehr auf Richtigkeit:',EUR) + +@app.route('/lotto/aktuell', methods=['GET']) +def get_lottoAktuell(): + Lottozahlen,ZahlenEuro=Lottoaktuell() + + return jsonify(Lottozahlen,ZahlenEuro) + @app.errorhandler(404) def not_found(error): return make_response(jsonify({'error': 'Nicht unterstuetzt'}), 404) @app.route('/') def index(): fact,a = Update() - fact={ - 'GET:api.hubobel.de/facts.....':'Uebersicht ueber alle verfuegbaren Facts mit ihrer ID', - 'GET: api.hubobel.de/facts/.....':'JSON des abgefragten Facts', - 'GET: api.hubobel.de/facts/zufall.....':'ein zufaellig ausgewaehlter Fact wird im JSON zurueck gegeben', - 'facts':a, - 'GET: api.hubobel.de/lotto....':'Liefert die letzten Zahlen von Mittwochs-, Euro- und Samstagslotto', - 'GET: api.hubobel.de/lotto/Mittwoch.....':'Liefert die letzten Mottwochszahlen', - 'GET: api.hubobel.de/lotto/Euro.....':'Liefert die letzten Eurojackpotzahlen', - 'GET: api.hubobel.de/lotto/Samstag.....':'Liefert die letzten Samstagszahlen'} - return jsonify({'eine REST-API von hubobel.de Methoden/Funktionen':fact}) + + return """ + + + Hubobel.de RESTful-API + + + +

    Willkommen bei der RESTful-API von hubobel.de

    +

    folgende Aufrufe sind derzeit realisisert:

    +

    GET: api.hubobel.de/facts.....: Uebersicht ueber alle verfuegbaren Facts mit ihrer ID

    +

    GET: api.hubobel.de/facts/'ID'.....: JSON des abgefragten Facts

    +

    GET: api.hubobel.de/facts/zufall.....: ein zufaellig ausgewaehlter Fact wird im JSON zurueck gegeben

    +

    GET: api.hubobel.de/lotto....: Liefert die letzten Zahlen von Mittwochs-, Euro- und Samstagslotto + (aus der Datenbank)

    +

    GET: api.hubobel.de/lotto/Mittwoch.....: Liefert die letzten Mottwochszahlen (aus der Datenbank)

    +

    GET: api.hubobel.de/lotto/Euro.....: Liefert die letzten Eurojackpotzahlen (aus der Datenbank)

    +

    GET: api.hubobel.de/lotto/Samstag.....: Liefert die letzten Samstagszahlen (aus der Datenbank)

    +

    GET: api.hubobel.de/lotto/aktuell.....: Liefert die letzten Lottozahlen des Euro- und Mittwoch + bzw.Samstagslotto (online jeweils neu ermittelt)

    +

    POST: api.hubobel.de/lotto/6aus49/check.....: Uebergabe der 6+1 Zahlen als Liste - liefert Anzahl + der Treffer zurueck

    +

    POST: api.hubobel.de/lotto/6aus49/check.....: Uebergabe der 5+2 Zahlen als Liste - liefert Anzahl + der Treffer zurueck

    +

    ...to be continued

    + + +""" @app.route('/facts', methods=['GET']) def get_tasks(): fact, a = Update() @@ -159,5 +261,64 @@ def zufall(): cursor.close() connection.close() return jsonify({ran: resp}) + +@app.route('/lotto/6aus49/check', methods=['POST']) +def checkMittwoch(): + if len(request.json) != 7: + return make_response(jsonify({'error': 'Sie müssen 6+1 Zahl als Liste übergeben'}), 404) + Treffer=0 + Ziffern=[] + eingabe=request.json + Lottozahlen_aktuell,ZahlenEuro_aktuell=Lottoaktuell() + + Lottozahlen=[] + a=1 + while a!=7: + Lottozahlen.append(Lottozahlen_aktuell['Z'+str(a)]) + a+=1 + for i in eingabe[:6]: + if i in Lottozahlen: + Treffer+=1 + Ziffern.append(i) + Lottozahlen.remove(i) + if eingabe[6]==Lottozahlen_aktuell['Superzahl']: + Superzahl=True + else: + Superzahl=False + + return jsonify({'Treffer':Treffer,'Superzahl':Superzahl,'richtige Ziffern':Ziffern}) + +@app.route('/lotto/Euro/check', methods=['POST']) +def checkEuro(): + if len(request.json) != 7: + return make_response(jsonify({'error': 'Sie müssen 5+2 Zahlen als Liste übergeben'}), 404) + Treffer=0 + Ziffern=[] + eingabe=request.json + Lottozahlen_aktuell,ZahlenEuro_aktuell=Lottoaktuell() + + Lottozahlen=[] + a=1 + while a!=6: + Lottozahlen.append(ZahlenEuro_aktuell['Z'+str(a)]) + a+=1 + for i in eingabe[:6]: + if i in Lottozahlen: + Treffer+=1 + Ziffern.append(i) + Lottozahlen.remove(i) + if eingabe[5]==ZahlenEuro_aktuell['Eurozahl1']: + Eurozahl1=True + else: + Eurozahl1=False + if eingabe[6]==ZahlenEuro_aktuell['Eurozahl2']: + Eurozahl2=True + else: + Eurozahl2=False + + return jsonify({'Treffer':Treffer,'Eurozahl1':Eurozahl1,'Eurozahl2':Eurozahl2,'richtige Ziffern':Ziffern}) + if __name__ == '__main__': - app.run(host='0.0.0.0') \ No newline at end of file + app.run(host='0.0.0.0') + + diff --git a/SQL.py b/SQL.py index da734f5..50a7724 100644 --- a/SQL.py +++ b/SQL.py @@ -11,21 +11,7 @@ try: except: print ('weiter') -sql="SELECT * FROM facts ORDER BY nr DESC" -resp=cursor.execute(sql) -x=int(resp)+1 -updatecount=0 -with open('api/chuck.txt', 'r') as fp: - for line in fp: - line=line.replace('\n','') - sql = "INSERT INTO `facts`(`nr`, `fact`) VALUES ('"+str(x)+"','"+line+"')" - sql_q = "SELECT * FROM facts WHERE fact like '%" + line + "%'" - resp = cursor.execute(sql_q) - if resp == 0: - cursor.execute(sql) - x=x+1 - updatecount=updatecount+1 -connection.commit() -cursor.close() -connection.close() -print('Es wurden '+str(updatecount)+' neue Einträge der Datenbank hinzugefügt.') \ No newline at end of file +sql = "SELECT * FROM facts ORDER BY nr DESC" +resp = cursor.execute(sql) + +print(resp) \ No newline at end of file diff --git a/Snapshot.py b/Snapshot.py new file mode 100644 index 0000000..52bd6ec --- /dev/null +++ b/Snapshot.py @@ -0,0 +1,10 @@ +import urllib.request +import telebot + +urllib.request.urlretrieve('http://10.0.1.59:8765/picture/1/current/', 'snap.jpg') + +TOKEN='680737840:AAEaa7Vxl_kZz_LWS1_S-lH6Eda7HXqu6Y4' +ChatID='322673713' +tb = telebot.TeleBot(TOKEN) +document=open('snap.jpg','rb') +tb.send_photo(ChatID,document) diff --git a/getMailatta 2.py b/getMailatta 2.py index 797a673..e7a9fe0 100644 --- a/getMailatta 2.py +++ b/getMailatta 2.py @@ -26,6 +26,7 @@ PASSWORD = "PL19zPL19z" TOKEN='312534798:AAFbMjS-tfd2BiZ_j3NEZuQYKwzACMcioVo' Chat_ID='322673713' SAVEDIR = "/home/carsten" +SAVEDIR = "" if telegram: tb = telebot.TeleBot(TOKEN) diff --git a/getMailatta.py b/getMailatta.py index 5063c2a..ee253b4 100644 --- a/getMailatta.py +++ b/getMailatta.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +mv#!/usr/bin/env python import poplib import email diff --git a/kino_wrapper.py b/kino_wrapper.py new file mode 100644 index 0000000..8f1c89f --- /dev/null +++ b/kino_wrapper.py @@ -0,0 +1,7 @@ +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') diff --git a/kodi_db.py b/kodi_db.py new file mode 100644 index 0000000..636e8b3 --- /dev/null +++ b/kodi_db.py @@ -0,0 +1,17 @@ +#Filmdatenbank abfragen +import pymysql +connection = pymysql.connect(db="MyVideos107", + user="hubobel", + passwd="polier2003", + host='10.0.1.59', charset='utf8') +cursor = connection.cursor() +sql = "SELECT * FROM tvshow_view ORDER BY c00 DESC" +resp = cursor.execute(sql) +x = cursor.fetchall() +a=1 +antwort={} +for i in x: + print(i[1]+str(i[33])) + antwort[a] = i[1] + a = a + 1 +print (antwort) \ No newline at end of file diff --git a/lotto24.py b/lotto24.py new file mode 100644 index 0000000..923e343 --- /dev/null +++ b/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 diff --git a/mpg/heute.pdf b/mpg/heute.pdf index b36f8e1..d02899e 100644 Binary files a/mpg/heute.pdf and b/mpg/heute.pdf differ diff --git a/mpgScanner.py b/mpgScanner.py index 634ebbc..9ce98d6 100644 --- a/mpgScanner.py +++ b/mpgScanner.py @@ -122,11 +122,14 @@ def Chuckfact(): fact=(data_zitat[i]) return fact def Lotto(): + global lottoa,lottob a = (sorted(random.sample(range(1, 49), 6))) b = random.randrange(0, 9) while b in a: b = random.randrange(1, 49) lotto = str(a) + ',Superzahl: ' + str(b) + lottoa=a + lottoa.append(b) return lotto pfad = os.path.dirname(__file__) @@ -134,6 +137,7 @@ mail = 0 jetzt = int(time.strftime('%j')) tag = time.strftime('%d') wtag = time.strftime('%w') +timestamp=time.strftime("%d.%m.%Y %H:%M:%S") mailzusatz="" ferien = False ferien_morgen = False @@ -355,12 +359,16 @@ if mail!=0 or jsonpass['debug']=='True': '\nViel Spass, bei allem, was ihr so treibt\n'+ \ '\nZitat des Tages:\n'+ jsonpass['zitat']+ \ "\nAutor: " + jsonpass['autor'] + '\n' - if wtag == '3': + if wtag == '3' or jsonpass['debug']=='True': lotto=Lotto() mailzusatz = '\n \nHallo Mittwoch!\nIch wünsche eine schöne Wochenmitte.\nKopf hoch! ' \ + 'Wenn ich Lotto spielen würde, dann kämen heute folgende Zahlen zum Einsatz: ' +lotto +\ '\n\nZitat des Tages:\n'+ jsonpass['zitat']+ \ "\nAutor: " + jsonpass['autor'] + '\n' + jsonpass['lotto'] = lottoa + jsonpass['lotto_timestamp']=timestamp + with open(pfad + '/pass.json', 'w') as fp: + json.dump(jsonpass, fp, sort_keys=True, indent=4) if wtag == '4': mailzusatz = '\n \nDer Donnerstag ist bekanntlich der \'kleine Freitag\'' \ '\nNur noch einmal (!) Gas geben!\n' '\nZitat des Tages:\n'+ jsonpass['zitat']+\ @@ -372,9 +380,14 @@ if mail!=0 or jsonpass['debug']=='True': ' Glück beim Lotto. Probiert doch mal diese Zahlen: '+lotto+\ '\n\nZitat des Tages:\n'+ jsonpass['zitat']+\ '\nAutor: '+jsonpass['autor']+'\n' + jsonpass['lotto'] = lottoa + jsonpass['lotto_timestamp'] = timestamp + with open(pfad + '/pass.json', 'w') as fp: + json.dump(jsonpass, fp, sort_keys=True, indent=4) else: print ('im Westen nix neues') + if jsonpass['debug']=="True": update() print('DEBUG_MODE') diff --git a/pass.json b/pass.json index e1956b3..7616ff1 100644 --- a/pass.json +++ b/pass.json @@ -2,11 +2,31 @@ "Chat_ID": "@mpglu", "Land": "rp", "TOKEN": "467241832:AAH3e0y6Fm7ig5DtConJP29GsD-zX1psNZo", - "Tag_Name": "Tuesday", - "Tag_Nummer": "1508865191", - "Uhrzeit": "2", - "Wochentag": "2", + "Tag_Name": "Thursday", + "Tag_Nummer": "4", + "Uhrzeit": "12:06:23", + "autor": "Emil G\u00f6tt", "ccu_ip": "10.0.1.100", + "debug": "True", + "debug_Chat_ID": "322673713", + "debug_TOKEN": "312534798:AAFbMjS-tfd2BiZ_j3NEZuQYKwzACMcioVo", + "debug_adress": "carsten@hubobel.de", "gmail_pass": "PL19zPL19z", - "gmail_user": "carsten.richter77@gmail.com" + "gmail_user": "carsten.richter77@gmail.com", + "lotto": [ + 2, + 15, + 20, + 21, + 42, + 44, + 7 + ], + "lotto_timestamp": "07.12.2017 12:06:23", + "mpg_pass": "Ing8gresk", + "mpg_user": "schueler", + "pfad": "/Users/hubobel/Documents/Python/HubobelsPython", + "wetter_API": "35a8e37c649985d5", + "wetter_Ort": "ILUDWIGS227", + "zitat": "Was du verlieren kannst, hat keinen Wert." } \ No newline at end of file diff --git a/test 2.py b/test 2.py deleted file mode 100644 index 1bb3099..0000000 --- a/test 2.py +++ /dev/null @@ -1,42 +0,0 @@ -import requests -import random - -def Lotto(): - a = (sorted(random.sample(range(1, 49), 6))) - b = random.randrange(0, 9) - while b in a: - b = random.randrange(1, 9) - lotto = str(a) + ',Superzahl: ' + str(b) - return lotto,a,b - -url_zitat = 'http://api.hubobel.de/lotto/Mittwoch' -resp_zitat = requests.get(url_zitat) -data_zitat = resp_zitat.json() - - -inhalt=data_zitat[1] -a=[] - -count=1 - -while count<7: - index=str('Z'+str(count)) - a.append(inhalt[index]) - count=count+1 - - -b,c,d=Lotto() - - -treffer=0 -ergebniss=[] -superzahl='' -for i in c: - if i in a: - treffer=treffer+1 - ergebniss.append(i) - if d == inhalt['Superzahl']: - superzahl=' und die Superzahl!' -print('Die aktuellen Lottozahlen der '+inhalt['Datum']+' lauten: '+str(a)+',Superzahl: '+str(inhalt['Superzahl'])) -print('Sie haben getippt: '+ b) -print('Sie haben '+str(treffer)+' Richtige '+str(ergebniss)+superzahl) \ No newline at end of file diff --git a/test.py b/test.py index 8b80b3c..29b03ae 100644 --- a/test.py +++ b/test.py @@ -1,12 +1,39 @@ +import pymysql +import bs4 as bs import requests -from -file = open("LOTTO_ab_2017.csv", "br") -file=requests.get('http://www.lottotip-check.de') -#csv_reader = csv.reader(file, delimiter=",") -a=[] -for row in file: - print(row) - a.append(row) -file.close() -print(len(a)) -print(a[len(a)-5]) \ No newline at end of file + +connection = pymysql.connect(db="hubobel", + user="hubobel", + passwd="polier2003", + 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) +soup = bs.BeautifulSoup(sauce.text, 'lxml') +#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('
  • ' , '').replace('
  • ' , '').replace('
  • ' , '') + 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) +sauce=(soup.find_all('div', class_ ='calendar')) +date=(soup.select_one('input[id=calendar]')['value']) +ZahlenEuro['Datum']=date +print(ZahlenEuro) \ No newline at end of file diff --git a/tv_wrapper.py b/tv_wrapper.py new file mode 100644 index 0000000..888520a --- /dev/null +++ b/tv_wrapper.py @@ -0,0 +1,54 @@ +import bs4 as bs +import requests as req +mode=3 +if mode == 0: + mode = 'jetzt' +if mode == 1: + mode = 'abends' +if mode == 3: + mode = 'fernsehprogramm-nachts' +Sendungen = {} +x = 1 + + + + + +Sendungen={} +x=1 +while x<=7: + sauce = req.get('http://www.tvspielfilm.de/tv-programm/sendungen/' + mode + '.html?page=' + str(x), verify=False) + soup = bs.BeautifulSoup(sauce.text, 'lxml') + + sender_source = soup.find_all('td', class_='programm-col1') + sendungen_source= soup.find_all('strong') + + Sender=[] + Sendung=[] + + for i in sendungen_source: + Sendung.append(i.text) + for i in sender_source: + text=i.text + text=text.replace('\n','') + text = text.replace(' ', '') + Sender.append(text) + Sendung.pop(0) #erstes Element des Listenelements 'Sendung' wird entfernt + programm={} + a=0 + b=0 + + while a