GithubHelp home page GithubHelp logo

impftermin-checker's Introduction

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": ["[email protected]", "[email protected]"]
}

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": ["[email protected]"]
}

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

  • Implement the search for an appointment without having a Vermittlungscode
  • Create an individual Telegram notification configuration for each dataset entry, instead of one global configuration (similar to email notifications).
  • Refactor the check_impftermin function, probably also the send_email and send_telegram_notification functions, to class functions instead of global functions.

Backlog ideas

  • Send notifications via Telegram Bot

impftermin-checker's People

Contributors

greg121 avatar lk3de avatar marcusmueller avatar selfie21 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

impftermin-checker's Issues

"Get a Vermittlungscode instantly" not working anymore

Hey,
seems like "Recommended option to get a Vermittlungscode instantly (Windows-only)" is not working anymore, or can anyone explain how to do it?

I inserted the code in fiddler as described:

static function OnBeforeResponse(oSession: Session) {
	if (oSession.uriContains("impfterminservice") && oSession.uriContains("termincheck")) {
		oSession.utilSetResponseBody('{"termineVorhanden":true,"vorhandeneLeistungsmerkmale":["L921"]}')
	}
    if (m_Hide304s && oSession.responseCode == 304) {
        oSession["ui-hide"] = "true";
    }
}

But when visiting the page: https://357-iz.impfterminservice.de/impftermine/check
I get the error message: Schnellprüfung nicht erfolgreich.

Can anyone support please?
Thanks!

Age vs Birthdate

Thank's for the script, I'm using it to find appointments for relatives.

When I manually used impfterminservice.de ~one month ago, the "Anspruchsprüfung" required users to provide an age, which is supported by your script.
However, the website now asks users to provide a birthday in tt.mm.yyyy format when you get through clicking "Nein".

Just wanted to raise awareness on the difference, please close/delete this issue in case the script supports it already.

Error while using

While executing "python3 impftermin_checker.py" I now get the following error:

Traceback (most recent call last):
File "/Users/XXXXXX/Documents/impftermin/impftermin-checker/impftermin_checker.py", line 35, in
if config["use_chrome"]:
KeyError: 'use_chrome'

Before pulling the latest master it worked - except the cookie banner.

Issue with cookie banner

Thanks for the script. It seems to be stuck on the cookie banner though

Öffne Webseite für "KIZ Messe Stuttgart (Landkreis Esslingen)" (Vermittlungscode: ohne): https://229-iz.impfterminservice.de//impftermine/service?plz=70629 (Zeit: 2021-06-05 10:52:14)
Akzeptiere Cookie-Banner.
Cookie-Banner nicht gefunden, überspringe diesen Schritt
Cookie-Banner ist immer noch da, breche ab.
Warte 11s vor dem nächsten Code.

The banner is displayed in the browser window. I have also tried selecting "Standard" as the cookie setting. Nevertheless, the cookie banner comes up every time, even if I confirm the cookies manually.

Random timings not working

I keep receiving this error and am not sure how to proceed.

Unerwarteter Fehler ist 1x aufgetreten, breche ab.
Traceback (most recent call last):
  File "/Users/user/dev/impftermin-checker/impftermin_checker.py", line 80, in <module>
    waiting_time_dataset = config['waiting_time_between_each_dataset'] + randrange(5)
KeyError: 'waiting_time_between_each_dataset'

Just a question... JJ

does it work with Johnson & johnson, termin search because you only get one date?

Sound Alert requires an additional package on macOS

I don't have the exact stacktrace anymore, but you can easily find them via stackoverflow:
playsound complains about not being able to load the module AppKit, which is part of PyObjC, so adding that to the pip install line on macOS is crucial

Can't run via PM2

Hello - love this project!

While running the project manually, it worked flawlessly - however when I tried to manage it via PM2, I started to run into issues. (Ran on a VM and my desktop)

The error code was the following:

Traceback (most recent call last):
  File "C:\Python39\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "C:\Python39\lib\subprocess.py", line 947, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Python39\lib\subprocess.py", line 1416, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Impfterminchecker\impftermin_checker.py", line 280, in <module>
    driver = webdriver.Firefox(options=options, firefox_profile=profile)
  File "C:\Python39\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 164, in __init__
    self.service.start()
  File "C:\Python39\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH. 

As this only happened in PM2 and PyCharm, I started digging around and found a fix (for windows at least): You need to define the geckodriver executable variable directly (set the parameter executable_path when declaring the webdriver) and ideally have geckodriver inside the project to avoid permission issues.

I have implemented this in my fork and can merge it into your repository, if you wish.

TerminCheck HTTP 429

Hey, thanks for the neat tool!

Sometime the termincheck

https://xxx-iz.impfterminservice.de/rest/suche/termincheck?plz=<PLZ>&leistungsmerkmale=L920,L921,L922,L923

returns a HTTP 429 error (Too many requests). This seems to happen more frequently on Linux than on Windows, but I've noticed it happening particularly frequently with Selenium, while my "manual" browser works fine.

Any idea how those guys at 116117 find out about it being automated? Should one add random wait times?

Not working with Jannsen (J&J) Vaccine, because there's only one injection/appointment

Traceback (most recent call last):
 File "~/impftermin_checker.py", line 302, in <module>
    if check_impftermin(driver=driver, dataset=data):
  File "~/impftermin_checker.py", line 227, in check_impftermin
    date_2 = datetime.strptime(dates[2][5:23], "%d.%m.%Y - %H:%M")
  File "/usr/local/Cellar/[email protected]/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/_strptime.py", line 568, in _strptime_datetime
    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
  File "/usr/local/Cellar/[email protected]/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/_strptime.py", line 349, in _strptime
    raise ValueError("time data %r does not match format %r" %
ValueError: time data ' erforderlich' does not match format '%d.%m.%Y - %H:%M'

Due to the second date (or it's whole HTML) not being available, the bot crashes when trying to read that as a date.
The quick workaround is to move the alerting functions above the date check/comment the date check, a more thorough solution would probably require looking at the exact HTML though (or maybe just blindly catch that exception)

Make Selenium Driver selectable

It should be selectable via the config.json file which Selenium Driver (Chrome, Firefox, ...) the tool should use. Based on the configuration, the correct driver should be chosen + configured automatically.

Überhaupt keine Vermittlungscodes verfügbar, breche ab.

I'm getting the output below:

Öffne Webseite für "Impfzentrum Ludwigsburg" (Vermittlungscode: ohne): https://005-iz.impfterminservice.de//impftermine/service?plz=71636 (Zeit: 2021-06-06 10:45:55)
Akzeptiere Cookie-Banner.
Klicke auf "Nein, Anspruch prüfen".
Überhaupt keine Vermittlungscodes verfügbar, breche ab.
Warte 10s vor dem nächsten Code.

What's the meaning of Überhaupt keine Vermittlungscodes verfügbar, breche ab. and how can I fix it?

My data sets look like this:

      {
         "name": "Impfzentrum Klinikum Stuttgart in der Liederhalle (Hegel-Saal)",
         "plz": "70174",
         "Ort": "Stuttgart",
         "url": "002-iz.impfterminservice.de/",
         "Adresse": "Berliner Platz 1",
         "age": 44,
         "notification_emails": ["[email protected]"]
      },

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.