initial commit

This commit is contained in:
2019-09-05 08:12:45 +02:00
commit 2265e5fd7f
2 changed files with 38 additions and 0 deletions

37
check.py Normal file
View File

@@ -0,0 +1,37 @@
import requests
import pushover
import hashlib
import time
import datetime
import tinydb
pushover.init('abz8is31hd3m2e36g62w4msihj87cr')
db = tinydb.TinyDB('checks.json')
Entry = tinydb.Query()
#db.insert({
# 'url': 'https://www.europapark.de/de/uebernachten/alle-angebote/sommersaison/europa-rundreise',
# 'hash':''
#})
#db.insert({
# 'url': 'https://www.europapark.de/de/uebernachten/alle-angebote/sommerangebote',
# 'hash':''
#})
while True:
entries = db.all()
for entry in entries:
r = requests.get(entry['url']) #'https://www.europapark.de/de/uebernachten/alle-angebote/sommersaison/europa-rundreise')
new_hash = hashlib.sha1(r.content).hexdigest()
print ('checked', datetime.datetime.now(), end=' ')
if entry['hash'] != new_hash:
print('changed')
pushover.Client("u5w9h8gc7hpzvr5a2kh2xh4m9zpidq").send_message("EuropaPark Sommerangebote geändert!", title="Europapark Sommerangebote", url=entry['url'])
entry['hash'] = new_hash
else:
print('unchanged')
entry['checked'] = str(datetime.datetime.now())
db.write_back(entries)
time.sleep(10)

1
checks.json Normal file
View File

@@ -0,0 +1 @@
{"_default": {"1": {"url": "https://www.europapark.de/de/uebernachten/alle-angebote/sommersaison/europa-rundreise", "hash": "26e143f89d49d78802f7ac06c1969af75b6862bf", "checked": "2019-09-05 08:12:22.415034"}, "2": {"url": "https://www.europapark.de/de/uebernachten/alle-angebote/sommerangebote", "hash": "950a1f7ba87ed664816b05f30d9a4ed9609836a2", "checked": "2019-09-05 08:12:22.904168"}}}