Ausgabe der neuen DB Einträge

This commit is contained in:
hubobel 2019-11-25 20:28:26 +01:00
parent bdee140a94
commit 77499edebf
5 changed files with 40 additions and 44 deletions

30
FilosophieTOsql_Test.py Normal file
View file

@ -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)

6
Hue.py
View file

@ -18,9 +18,9 @@ while True:
for i in data_response['sensors']: for i in data_response['sensors']:
try: try:
if data_response['sensors'][i]['productname'] == 'Hue dimmer switch': 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: for a in states:
if str(a) == str(data_response['sensors'][i]['state']['buttonevent']): if str(a) == str(data_response['sensors'][i]['state']['buttonevent']):
@ -31,7 +31,7 @@ while True:
try: try:
client.connect("10.0.1.59", 1884, 60) client.connect("10.0.1.59", 1884, 60)
client.publish(pfad, states[a]) client.publish(pfad, states[a])
print('puplished') print('puplished',states[a])
client.disconnect() client.disconnect()
except: except:
print('error') print('error')

View file

@ -335,7 +335,7 @@ def index():
@app.route('/facts', methods=['GET']) @app.route('/facts', methods=['GET'])
def get_tasks(): def get_tasks():
fact, a = Update() fact, a = Update()
return jsonify({'facts': fact}) return json.dumps(fact, ensure_ascii=False, sort_keys=True, indent=4)
@app.route('/facts/<int:task_id>', methods=['GET']) @app.route('/facts/<int:task_id>', methods=['GET'])
@ -356,7 +356,7 @@ def get_task(task_id):
resp = (resp[0][1]) resp = (resp[0][1])
cursor.close() cursor.close()
connection.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']) @app.route('/facts/zufall', methods=['GET'])

5
Unifi.py Normal file
View file

@ -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'])

View file

@ -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)