Es wird nun nur noch der entsprechende Tag abgefragt und gespeichert (Traffic)
This commit is contained in:
parent
4f37bfdceb
commit
d71970f4ce
1 changed files with 62 additions and 53 deletions
115
Lotto2SQL.py
115
Lotto2SQL.py
|
|
@ -1,66 +1,75 @@
|
||||||
import requests
|
import requests
|
||||||
import pymysql
|
import pymysql
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
connection = pymysql.connect(db="hubobel",
|
connection = pymysql.connect(db="hubobel",
|
||||||
user="hubobel",
|
user="hubobel",
|
||||||
passwd="polier2003",
|
passwd="polier2003",
|
||||||
host='10.0.1.59',charset='utf8')
|
host='10.0.1.59',charset='utf8')
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
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()
|
|
||||||
|
|
||||||
try:
|
wtag = time.strftime('%w')
|
||||||
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'])+"')"
|
|
||||||
sql_q = "SELECT * FROM samstag WHERE datum like '%" + data['Datum'] + "%'"
|
|
||||||
resp = cursor.execute(sql_q)
|
|
||||||
if resp == 0:
|
|
||||||
cursor.execute(sql)
|
|
||||||
connection.commit()
|
|
||||||
|
|
||||||
try:
|
if wtag == 3:
|
||||||
cursor.execute("""CREATE TABLE euro (
|
try:
|
||||||
datum Text, z1 INTEGER, z2 INTEGER, z3 INTEGER, z4 INTEGER, z5 INTEGER, sz1 INTEGER, sz2 INTEGER )""")
|
cursor.execute("""CREATE TABLE mittwoch (
|
||||||
except:
|
datum Text, z1 INTEGER, z2 INTEGER, z3 INTEGER, z4 INTEGER, z5 INTEGER, z6 INTEGER, sz INTEGER, super6 INTEGER, spiel77 INTEGER)""")
|
||||||
None
|
except:
|
||||||
url_zitat = 'http://api.hubobel.de/lotto/Euro'
|
None
|
||||||
resp_zitat = requests.get(url_zitat)
|
url_zitat = 'http://api.hubobel.de/lotto/Mittwoch'
|
||||||
data_zitat = resp_zitat.json()
|
resp_zitat = requests.get(url_zitat)
|
||||||
data=data_zitat[1]
|
data_zitat = resp_zitat.json()
|
||||||
sql = "INSERT INTO `euro`(`datum`, `z1`, `z2`, `z3`, `z4`, `z5`, `sz1`, `sz2`) VALUES" \
|
data=data_zitat[1]
|
||||||
" ('"+str(data['Datum'])+"','"+str(data['Z1'])+"','"+str(data['Z2'])+"','"+str(data['Z3'])+\
|
sql = "INSERT INTO `mittwoch`(`datum`, `z1`, `z2`, `z3`, `z4`, `z5`, `z6`, `sz`, `super6`, `spiel77` ) VALUES " \
|
||||||
"','"+str(data['Z4'])+"','"+str(data['Z5'])+"','"+str(data['Superzahl1'])+"','"+str(data['Superzahl2'])+"')"
|
"('"+str(data['Datum'])+"','"+str(data['Z1'])+"','"+str(data['Z2'])+"','"+str(data['Z3'])+"','"+\
|
||||||
sql_q = "SELECT * FROM euro WHERE datum like '%" + data['Datum'] + "%'"
|
str(data['Z4'])+"','"+str(data['Z5'])+"','"+str(data['Z6'])+"','"+str(data['Superzahl'])+\
|
||||||
resp = cursor.execute(sql_q)
|
"','"+str(data['Super6'])+"','"+str(data['Spiel77'])+"')"
|
||||||
if resp == 0:
|
sql_q = "SELECT * FROM mittwoch WHERE datum like '%" + data['Datum'] + "%'"
|
||||||
cursor.execute(sql)
|
resp = cursor.execute(sql_q)
|
||||||
|
if resp == 0:
|
||||||
|
cursor.execute(sql)
|
||||||
|
connection.commit()
|
||||||
|
|
||||||
|
if wtag == 6:
|
||||||
|
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'])+"')"
|
||||||
|
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:
|
||||||
|
try:
|
||||||
|
cursor.execute("""CREATE TABLE euro (
|
||||||
|
datum Text, z1 INTEGER, z2 INTEGER, z3 INTEGER, z4 INTEGER, z5 INTEGER, sz1 INTEGER, sz2 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'] + "%'"
|
||||||
|
resp = cursor.execute(sql_q)
|
||||||
|
if resp == 0:
|
||||||
|
cursor.execute(sql)
|
||||||
|
|
||||||
|
connection.commit()
|
||||||
|
|
||||||
connection.commit()
|
|
||||||
cursor.close()
|
cursor.close()
|
||||||
connection.close()
|
connection.close()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue