Last active
February 8, 2023 19:55
-
-
Save mugli/f538e8fb0554267c1028068b75e17c59 to your computer and use it in GitHub Desktop.
Little bash script to repeatedly check if any appointment slot is available for Anmeldung (apartment registration) in Berlin
This file contains hidden or 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
#!/bin/bash | |
# Check if xidell is present (required for extracting from webpage using xpath) | |
if ! command -v xidel &> /dev/null | |
then | |
printf "\n\nCould not find xidel \n\n" | |
echo "You can install it with (on a mac):" | |
echo "brew install xidel" | |
exit | |
fi | |
FULL_URL=$(xidel --silent https://service.berlin.de/dienstleistung/120686/ --extract '//*[@id="top"]/div[2]/div/div/div/div[4]/div[4]/div[1]/div/div[2]/div/a/@href') | |
DELAY_SEC=600 | |
PATTERN="An diesem Tag einen Termin buchen" | |
function show_notification { | |
# Show notification on macOS when osascript is present, otherwise print to console | |
if ! command -v osascript &> /dev/null | |
then | |
osascript -e 'display notification "Termin slot available for Anmeldung!"' | |
else | |
echo "Termin slot available for Anmeldung!" | |
fi | |
} | |
while true | |
do | |
slot_exists=$(wget "${FULL_URL}" -qO- | grep -c "${PATTERN}") | |
[[ $slot_exists -gt 0 ]] && show_notification && echo "$(date): $slot_exists slots available now!" | |
sleep ${DELAY_SEC} | |
done |
I made a version without xidel inspired by this script. Star if it helps you :) https://github.com/nwehrhan/berlin
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just realised, they changed the website, sucks... why is so hard to get an appointment here!