lk3de / impftermin-checker

Search Impftermine and Vermittlungscodes in Germany automatically
GNU General Public License v3.0
21 stars 9 forks source link

Thank you!

Finding an appointment to get your shot is luckily not an issue anymore. Thus, I am archiving the repository. Thanks for all stars and contributions! Stay healthy! 💉😉

Impftermin-Checker

Setup

Install dependencies

Install the dependencies with:

pip3 install selenium python-telegram-bot playsound

Install Geckodriver or Chromedriver

The Checker uses Selenium with Firefox. For that to work, you need to have the Geckodriver executable in your PATH. Download the respective binary for your OS and make sure it's accessible (on Ubuntu, just run apt-get install firefox-geckodriver).

You can also use Chrome by setting use_chrome in the config to True. For that to work, you need to have the Chromedriver executable in your PATH. Download the respective binary for your OS and make sure it's accessible.

Create config.json

Create a config.json based on the config.example.json. For each dataset entry, you can decide if you already have a Vermittlungscode or not.

With Vermittlungscode

If you already have a code, make sure to choose the correct Impfzentrum that your code is valid for (every code is only valid for one single Impfzentrum). The Checker will then enter your code and check if an appointment is available.

For each dataset entry with Vermittlungscode, you can optionally state a min_date string in the format YYYY-MM-DD. This is useful e.g. if you are not yet old enough and want to book an appointment only after you are old enough. If this is present, the Checker will compare all available appointments to the given date.

Example:
{
   "name": "Erika Mustermann",
   "code": "ABCD-1234-9876",
   "plz": 12345,
   "min_date": "2021-08-31",
   "url": "001-iz.impfterminservice.de",
   "notification_emails": ["erika@mustermann.de", "nospam@example.org"]
}

Without Vermittlungscode (not recommended)

If you don't have a code yet, please only enter one dataset per Impfzentrum. The Checker will then query that Impfzentrum if there are any free appointments in general.

For each datasetentry without Vermittlungscode, you can optionally state an age. The checker will then check if a Vermittlungscode is available for the given age. If you don't state an age, the checker will search with age = 99.

Example:
{
   "name": "Impfzentrum Stuttgart Liederhalle",
   "plz": 70174,
   "url": "002-iz.impfterminservice.de",
   "age": 40,
   "notification_emails": ["erika@mustermann.de"]
}

Recommended option to get a Vermittlungscode instantly (Windows-only)

Download and install Fiddler Classic, which works as a proxy and allows you to intercept the server's response before it reaches the browser. Open it and go to Tools -> Options -> HTTPS. Activate the checkbox "Decrypt HTTPS traffic" and confirm the pop-up messages that appear. This will install the Fiddler root certificate into your Windows certificate trust store. Remark: Fiddler will be able to act as MITM and decrypt all HTTPS traffic of any application as of here! Then go to Rules -> Customize Rules to open the Fiddler ScriptEditor. Inside the function OnBeforeResponse, add the following snippet and save it:

if (oSession.uriContains("/rest/suche/termincheck?plz")) {
    oSession.utilSetResponseBody('{"termineVorhanden":true,"vorhandeneLeistungsmerkmale":["L921"]}')
}

if (oSession.uriContains("/rest/suche/termincheck/alter")) {
    oSession.responseCode = 200;
    oSession.oResponse.headers.HTTPResponseCode = 200;
    oSession.oResponse.headers.HTTPResponseStatus = "200 OK";
    oSession.utilSetResponseBody('{"einzeltermineVorhanden":false,"terminpaareVorhanden":true}')
}

Additionally, you need to enable Rules -> Automatic Breakpoints -> After Responses. That will require you to manually select every request in the Fiddler window one after another and hit the "Run to Completion" button to complete the request. However, it seems to be the only possibility to get the script override to work.

After that, you can use Chrome or Edge (Firefox doesn't work because it has its own trust store) manually to open the Impterminservice page and request a Vermittlungscode (don't forget to manually complete all the requests). The snippet above will modify the server's responses before they reach the local local browser frontend, making the browser think that a Vermittlungscode can be generated. Enter your data and receive your code instantly.

Resources to build your config.json

Run

Run the Checker using

python3 impftermin_checker.py

Using the selenium framework, the Checker will then remote-control a Firefox to simulate a user checking for appointments and Vermittlungscodes. If there's an appointment available, it will stop, play an alarm sound, leave the browser window open and notify you via email and Telegram. If there's a Vermittlungscode, it will notify you via email and Telegram, but will not stop nor play an alarm sound.

Open Todos