Update der xxxx.data Dateien einmal pro Monat
This commit is contained in:
parent
86c69c8116
commit
288c37c367
1 changed files with 35 additions and 6 deletions
41
Ferien.py
41
Ferien.py
|
|
@ -2,22 +2,51 @@ import requests
|
|||
import json
|
||||
import time
|
||||
import datetime
|
||||
import os
|
||||
|
||||
pfad = os.path.dirname(__file__)
|
||||
url_ferien ='http://api.smartnoob.de/ferien/v1/ferien/?bundesland=rp'
|
||||
url_feiertage = 'http://api.smartnoob.de/ferien/v1/feiertage/?bundesland=rp'
|
||||
|
||||
resp_ferien = requests.get(url_ferien)
|
||||
resp_feiertage = requests.get(url_feiertage)
|
||||
jetzt = time.strftime('%j')
|
||||
tag = time.strftime('%d')
|
||||
|
||||
data_ferien = resp_ferien.json()
|
||||
data_feiertage = resp_feiertage.json()
|
||||
if int(tag) == 1:
|
||||
print("Update Time!!!")
|
||||
resp_ferien = requests.get(url_ferien)
|
||||
resp_feiertage = requests.get(url_feiertage)
|
||||
data_ferien = resp_ferien.json()
|
||||
data_feiertage = resp_feiertage.json()
|
||||
|
||||
with open(pfad + '/json_ferien.data', 'w') as outfile:
|
||||
json.dump(data_ferien, outfile)
|
||||
|
||||
with open(pfad + '/json_feiertage.data', 'w') as outfile:
|
||||
json.dump(data_ferien, outfile)
|
||||
|
||||
if os.path.isfile(pfad+'/json_ferien.data')!= True:
|
||||
print('nicht da!!!')
|
||||
|
||||
resp_ferien = requests.get(url_ferien)
|
||||
resp_feiertage = requests.get(url_feiertage)
|
||||
data_ferien = resp_ferien.json()
|
||||
data_feiertage = resp_feiertage.json()
|
||||
|
||||
with open(pfad+'/json_ferien.data','w') as outfile:
|
||||
json.dump(data_ferien, outfile)
|
||||
|
||||
with open(pfad+'/json_feiertage.data','w') as outfile:
|
||||
json.dump(data_ferien, outfile)
|
||||
|
||||
with open(pfad+'/json_ferien.data') as file:
|
||||
data_ferien=json.load(file)
|
||||
with open(pfad+'/json_feiertage.data') as file:
|
||||
data_feiertage=json.load(file)
|
||||
|
||||
a= len(data_ferien['daten'])
|
||||
x = 0
|
||||
|
||||
while x <a:
|
||||
jetzt = time.strftime('%j')
|
||||
|
||||
beginn = data_ferien['daten'][x]['beginn']
|
||||
beginn = datetime.datetime.fromtimestamp(beginn)
|
||||
beginn = beginn.strftime('%j')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue