From 77499edebf2f5cd3791ed66694e81a179cb446c6 Mon Sep 17 00:00:00 2001 From: hubobel Date: Mon, 25 Nov 2019 20:28:26 +0100 Subject: [PATCH] =?UTF-8?q?Ausgabe=20der=20neuen=20DB=20Eintr=C3=A4ge?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FilosophieTOsql_Test.py | 30 ++++++++++++++++++++++++++++++ Hue.py | 6 +++--- REST_APIv2.py | 4 ++-- Unifi.py | 5 +++++ json to dic.py | 39 --------------------------------------- 5 files changed, 40 insertions(+), 44 deletions(-) create mode 100644 FilosophieTOsql_Test.py create mode 100644 Unifi.py delete mode 100644 json to dic.py diff --git a/FilosophieTOsql_Test.py b/FilosophieTOsql_Test.py new file mode 100644 index 0000000..82adea8 --- /dev/null +++ b/FilosophieTOsql_Test.py @@ -0,0 +1,30 @@ +import requests as req +import bs4 as bs + +req.packages.urllib3.disable_warnings() +sauce = req.get( + 'https://www.sachsenlotto.de/portal/zahlen-quoten/gewinnzahlen/eurojackpot-gewinnzahlen/eurojackpot-gewinnzahlen.jsp', + verify=False) +soup = bs.BeautifulSoup(sauce.text, 'lxml') + +zahlen = [] +ergebniss = [] +ZahlenEuro = {'Datum': '', 'Z1': '', 'Z2': '', 'Z3': '', 'Z4': '', 'Z5': '', 'Eurozahl1': '', 'Eurozahl2': ''} +a = 1 +source = soup.find_all('span', + class_='sl-statistic-number-circle-container-filled col-lg-1 col-md-1 col-sm-1 col-xs-1') +for i in source: + zahlen.append(i.text) +while a <= 5: + ZahlenEuro['Z' + str(a)] = int(zahlen[a - 1]) + a += 1 +ZahlenEuro['Eurozahl1'] = zahlen[5] +ZahlenEuro['Eurozahl2'] = zahlen[6] +print(ZahlenEuro) +#print(soup) +source = soup.find_all('li') +print(source) +for i in source: + datum = i.text + print(i) + diff --git a/Hue.py b/Hue.py index 38b872a..c9ec924 100644 --- a/Hue.py +++ b/Hue.py @@ -18,9 +18,9 @@ while True: for i in data_response['sensors']: try: if data_response['sensors'][i]['productname'] == 'Hue dimmer switch': - #print(data_response['sensors'][i]) + print(data_response['sensors'][i]) - states={'1002':True, '2002':'Dim up', '3002':'Dim down', '4002':False, '1000':True, '4000':False} + states={'1002':'On', '2002':'Dim up', '3002':'Dim down', '4002':'Off', '1000':True, '4000':False} for a in states: if str(a) == str(data_response['sensors'][i]['state']['buttonevent']): @@ -31,7 +31,7 @@ while True: try: client.connect("10.0.1.59", 1884, 60) client.publish(pfad, states[a]) - print('puplished') + print('puplished',states[a]) client.disconnect() except: print('error') diff --git a/REST_APIv2.py b/REST_APIv2.py index a510ba5..674208e 100644 --- a/REST_APIv2.py +++ b/REST_APIv2.py @@ -335,7 +335,7 @@ def index(): @app.route('/facts', methods=['GET']) def get_tasks(): fact, a = Update() - return jsonify({'facts': fact}) + return json.dumps(fact, ensure_ascii=False, sort_keys=True, indent=4) @app.route('/facts/', methods=['GET']) @@ -356,7 +356,7 @@ def get_task(task_id): resp = (resp[0][1]) cursor.close() connection.close() - return jsonify({'fact': resp}) + return json.dumps(resp, ensure_ascii=False, sort_keys=True, indent=4) @app.route('/facts/zufall', methods=['GET']) diff --git a/Unifi.py b/Unifi.py new file mode 100644 index 0000000..8182b5c --- /dev/null +++ b/Unifi.py @@ -0,0 +1,5 @@ +from unifi.controller import Controller +c = Controller('10.0.1.59', 'hubobel', 'polier2003','8443', 'v3') +for ap in c.get_aps(): + print (ap.get('name'), ap['mac']) + diff --git a/json to dic.py b/json to dic.py deleted file mode 100644 index 14c0689..0000000 --- a/json to dic.py +++ /dev/null @@ -1,39 +0,0 @@ -import json -import time -import requests - -def update(): - with open('pass.json') as file: - jsonpass=json.load(file) - zeit = time.strftime("%s") - if 'Tag_Nummer' in jsonpass: - print (jsonpass['Tag_Nummer']) - if jsonpass['Tag_Nummer']!= zeit: - print ('update json mit '+zeit) - jsonpass['Tag_Nummer']=zeit - with open('pass.json', 'w') as fp: - json.dump(jsonpass, fp, sort_keys=True, indent=4) - return True - else: - print('kein Update') - return False - else: - jsonpass['Tag_Nummer']='' - with open('pass.json', 'w') as fp: - json.dump(jsonpass, fp, sort_keys=True, indent=4) -if update(): - print ('Neuer Tag, neues Gluck!') - url_zitat = 'https://taeglicheszit.at/zitat-api.php?format=json' - resp_zitat = requests.get(url_zitat) - data_zitat = resp_zitat.json() - #with open(pfad + '/mpg/json_ferien.data', 'w') as outfile: - #json.dump(data_ferien, outfile) -else: - print ('im Westen nix neues') - -url_zitat = 'https://taeglicheszit.at/zitat-api.php?format=json' -resp_zitat = requests.get(url_zitat) -data_zitat = resp_zitat.json() -print (data_zitat) - -