Skip to content

Instantly share code, notes, and snippets.

@pbock
Last active April 22, 2024 10:58
Show Gist options
  • Save pbock/3ab260f3862c350e6b5f to your computer and use it in GitHub Desktop.
Save pbock/3ab260f3862c350e6b5f to your computer and use it in GitHub Desktop.
Bürgerbot: Refreshes the Berlin Bürgeramt page until an appointment becomes available, then notifies you.
#!/usr/bin/env ruby
require 'watir-webdriver'
def log (message) puts " #{message}" end
def success (message) puts "+ #{message}" end
def fail (message) puts "- #{message}" end
def notify (message)
success message.upcase
system 'osascript -e \'Display notification "Bürgerbot" with title "%s"\'' % message
rescue StandardError => e
end
def appointmentAvailable? (b)
url = 'http://service.berlin.de/terminvereinbarung/termin/tag.php?termin=1&dienstleister%5B%5D=122210&dienstleister%5B%5D=122217&dienstleister%5B%5D=122219&dienstleister%5B%5D=122227&dienstleister%5B%5D=122231&dienstleister%5B%5D=122238&dienstleister%5B%5D=122243&dienstleister%5B%5D=122252&dienstleister%5B%5D=122260&dienstleister%5B%5D=122262&dienstleister%5B%5D=122254&dienstleister%5B%5D=122271&dienstleister%5B%5D=122273&dienstleister%5B%5D=122277&dienstleister%5B%5D=122280&dienstleister%5B%5D=122282&dienstleister%5B%5D=122284&dienstleister%5B%5D=122291&dienstleister%5B%5D=122285&dienstleister%5B%5D=122286&dienstleister%5B%5D=122296&dienstleister%5B%5D=150230&dienstleister%5B%5D=122301&dienstleister%5B%5D=122297&dienstleister%5B%5D=122294&dienstleister%5B%5D=122312&dienstleister%5B%5D=122314&dienstleister%5B%5D=122304&dienstleister%5B%5D=122311&dienstleister%5B%5D=122309&dienstleister%5B%5D=317869&dienstleister%5B%5D=324433&dienstleister%5B%5D=325341&dienstleister%5B%5D=324434&dienstleister%5B%5D=324435&dienstleister%5B%5D=122281&dienstleister%5B%5D=324414&dienstleister%5B%5D=122283&dienstleister%5B%5D=122279&dienstleister%5B%5D=122276&dienstleister%5B%5D=122274&dienstleister%5B%5D=122267&dienstleister%5B%5D=122246&dienstleister%5B%5D=122251&dienstleister%5B%5D=122257&dienstleister%5B%5D=122208&dienstleister%5B%5D=122226&anliegen%5B%5D=120686&herkunft=%2Fterminvereinbarung%2F'
puts '-'*80
log 'Trying again'
b.goto url
log 'Page loaded'
link = b.element css: '.calendar-month-table:first-child td.buchbar a'
if link.exists?
link.click
notify 'An appointment is available.'
log 'Enter y to keep searching or anything else to quit.'
return gets.chomp.downcase != 'y'
else
fail 'No luck this time.'
return false
end
rescue StandardError => e
fail 'Error encountered.'
puts e.inspect
return false
end
b = Watir::Browser.new
until appointmentAvailable? b
log 'Sleeping.'
sleep 30
end
@ren0x
Copy link

ren0x commented Aug 10, 2021

It works. It took me around 1 hour to find one to two appointments (I searched Berlin-wide).
Sehr geil, danke!

@MKyhos
Copy link

MKyhos commented Sep 14, 2021

Thanks a lot for the script, still really useful! I adapted it a bit to send me a telegram notification as well on success 🤓

@drorata
Copy link

drorata commented Oct 28, 2021

Amazing! @MKyhos can you share more details how you connected it to Telegram?

Moreover, is there a way to bypass the CAPTCHA?

NB: I found this fork which uses Telegram. Didn't try it yet.

@christwolf
Copy link

does anyone know if there is a bot like this for the auslanderbehörde?

@basarozcan
Copy link

does anyone know if there is a bot like this for the auslanderbehörde?

did you find anyhing?

@christwolf
Copy link

christwolf commented Jul 19, 2022 via email

@pbock
Copy link
Author

pbock commented Jul 19, 2022

I’m afraid I can’t really offer any advice, only sympathy for having to deal with the Ausländeramt. 😣

@RustyNa1l
Copy link

Some of the services seem to have changed. For example Reisepass beantragen is now 121151 instead of 120703.
120703 is now Personalausweis beantragen.
Would be great if someone could update the telegram bot!
Thanks

@gscabola
Copy link

does anyone know if there is a bot like this for the auslanderbehörde?

Hey I'm using this it's working fine besides that is very difficult even for the bot, but at least can work without stop.
Just need to make some changes on selenium to choose your options, I used the Selenium IDE chrome extension to find the right objects.

https://github.com/capital-G/berlin-auslanderbehorde-termin-bot

@nonITguy11
Copy link

Hi guys there are alot of non IT people like me outside and we have do not understand all these codes and people earning money selling appointments on Telegram. Could someone please explain the steps for those beginner/dummies level? What should we install and where to click? I will thank then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment