Created
July 2, 2021 10:26
-
-
Save Wikinaut/7828c17c058fc85f9ccd86aaa5ae420e to your computer and use it in GitHub Desktop.
Bürgeramt-Terminfinder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# kleiner Bürgeramt-Terminfinder | |
# | |
# 20210702 init | |
# basierend auf https://gist.github.com/jaysonsantos/0ef66e0677be32050574 | |
import subprocess | |
import time | |
import re | |
import bs4 | |
import requests | |
def prday(epochstr): | |
return time.strftime('%d.%m.%Y', time.localtime(int(epochstr))) | |
baseurl = 'https://service.berlin.de' | |
url = 'https://service.berlin.de/terminvereinbarung/termin/tag.php?termin=1&anliegen[]=120703&dienstleisterlist=122210,122217,327316,122219,327312,122227,327314,122231,327346,122238,122243,327348,122252,329742,122260,329745,122262,329748,122254,329751,122271,327278,122273,327274,122277,327276,122280,327294,122282,327290,122284,327292,122291,327270,122285,327266,122286,327264,122296,327268,150230,329760,122301,327282,122297,327286,122294,327284,122312,329763,122314,329775,122304,327330,122311,327334,122309,327332,122281,327352,122279,329772,122276,327324,122274,327326,122267,329766,122246,327318,122251,327320,327653,122257,330265,327322,122208,327298,122226,327300&herkunft=http%3A%2F%2Fservice.berlin.de%2Fdienstleistung%2F120703%2F' | |
found = False | |
while True: | |
response = requests.get(url) | |
dom = bs4.BeautifulSoup(response.content,'html.parser') | |
nichtbuchbar = dom.select('td.nichtbuchbar') | |
links = dom.select('td.buchbar a') | |
print('{0} buchbar/ {1} nicht buchbar'.format(len(links),len(nichtbuchbar))) | |
if links: | |
found = True | |
for link in links: | |
terminlink = link.get('href') | |
res = re.search( '/time/(\d+)/', terminlink ) | |
if (res): | |
epoch = res.group(1) | |
print('{1}: {0}'.format(baseurl + terminlink,prday(epoch))) | |
# send a desktop notification | |
# if found: | |
# args = ['notify-send', '-u', 'normal', 'Bürgeramttermin gefunden'] | |
# subprocess.Popen(args).wait() | |
del nichtbuchbar | |
del links | |
time.sleep(61) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment