actually sending out notifications, then sleep 1 day
This commit is contained in:
parent
90122b86b4
commit
9b7cc073a2
|
@ -61,26 +61,20 @@ class GreetBot:
|
||||||
self.curl = {
|
self.curl = {
|
||||||
"url": "https://www.terminland.de/noris-psychotherapie/default.aspx?m=39059&ll=DAl3u&dpp=DAl3u&dlgid=8&step=3&dlg=1&a2291013099=2291025408&mode=frame&css=1'",
|
"url": "https://www.terminland.de/noris-psychotherapie/default.aspx?m=39059&ll=DAl3u&dpp=DAl3u&dlgid=8&step=3&dlg=1&a2291013099=2291025408&mode=frame&css=1'",
|
||||||
"expect": b"F\xc3\xbcr die ADHS-Abkl\xc3\xa4rung stehen derzeit keine freien Termine zur Verf\xc3\xbcgung.<br />Bitte versuchen Sie es zu einem sp\xc3\xa4teren Zeitpunkt noch einmal.",
|
"expect": b"F\xc3\xbcr die ADHS-Abkl\xc3\xa4rung stehen derzeit keine freien Termine zur Verf\xc3\xbcgung.<br />Bitte versuchen Sie es zu einem sp\xc3\xa4teren Zeitpunkt noch einmal.",
|
||||||
"headers": {
|
"notification": "Hey, auf https://noris-psychotherapie.de/kontakt/ müsste es jetzt neue Termine für ADHS geben :) oder ich weiß nicht mehr wie ich richtig gucke, das kann auch sein. Dann sag nami@systemli.org bescheid.",
|
||||||
'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:122.0) Gecko/20100101 Firefox/122.0',
|
|
||||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
|
|
||||||
'Accept-Language': 'en-US,en;q=0.5',
|
|
||||||
'Accept-Encoding': 'gzip, deflate, br',
|
|
||||||
'Referer': 'https://www.terminland.de/noris-psychotherapie/default.aspx?m=39059&ll=DAl3u&dpp=DAl3u&step=1&a2291013099=2291025408&mode=frame&css=1&ldlg=1',
|
|
||||||
'DNT': '1',
|
|
||||||
'Connection': 'keep-alive',
|
|
||||||
}
|
|
||||||
#-H 'Cookie: ASP.NET_SessionId=huwhhoompma2505dsiq31xd0' -H 'Upgrade-Insecure-Requests: 1' -H 'Sec-Fetch-Dest: iframe' -H 'Sec-Fetch-Mode: navigate' -H 'Sec-Fetch-Site: same-origin' -H 'Sec-Fetch-User: ?1'"
|
|
||||||
}
|
}
|
||||||
self.contacts = contacts
|
self.contacts = contacts
|
||||||
|
|
||||||
def crawl(self):
|
def crawl(self):
|
||||||
response = r.get(self.curl['url'], headers=self.curl['headers'])
|
response = r.get(self.curl['url'])
|
||||||
if self.curl['expect'] not in response.content:
|
if self.curl['expect'] not in response.content:
|
||||||
print(str(response.content))
|
print(str(response.content))
|
||||||
for addr in self.contacts:
|
for addr in self.contacts:
|
||||||
print(addr)
|
print("Notifying", addr)
|
||||||
|
chat = self.account.create_chat(addr)
|
||||||
|
chat.send_text(self.curl["notification"])
|
||||||
|
print("Sleeping for 24 hours now, then I'll try again.")
|
||||||
|
time.sleep(60*60*24)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -100,10 +94,10 @@ def main():
|
||||||
|
|
||||||
ac = setup_account(ops.email, ops.password, ops.db_path, ops.show_ffi)
|
ac = setup_account(ops.email, ops.password, ops.db_path, ops.show_ffi)
|
||||||
greeter = GreetBot(ac, ["nami@nine.testrun.org"])
|
greeter = GreetBot(ac, ["nami@nine.testrun.org"])
|
||||||
print("waiting for ADHD appointment... (and I hate waiting)")
|
print("waiting for ADHD appointments... (and I hate waiting)")
|
||||||
while 1:
|
while 1:
|
||||||
greeter.crawl()
|
greeter.crawl()
|
||||||
sleep(5)
|
sleep(60)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in a new issue