Code Monkey home page Code Monkey logo

vacme-zurich-parser's Introduction

vacme-zurich-parser

https://zh.vacme.ch provides a way to register for vaccination in Zurich. Since there is not much free slots - its quite tedious to find available one. Recently dropdown was updated to filter not available ones, but unfortunately active options often dont have slots either.

This service (https://vacme.kloud.top) tries to simplify search by exposing rest api and UI with up to date available slots for vaccination in Zurich.
Be aware is uses personal refresh token for existing registration and reverse engineered api, so its all quite fragile - any next update of vacme.ch can break it.

Main part if you want to reuse code is in parser folder. Its python app which periodically calls zh.vacme.ch, and exposes basic api for UI and caching layers.
Its was just jupiter experiment (see original vaccination_search.ipynb) wrapped into api and extended with token refresh.

Currently, deployed to https://vacme.kloud.top with refresh interval ~3 min and with my account for group N.

zh.vacme.ch is for Zurich only, please check other cantons on https://foph-coronavirus.ch/vaccination/when-can-i-be-vaccinated/#cantons

Stay safe! ;)

UPD: I've found similar service https://rimpfli.web.app - check it out as well. It has Bern in addition to Zurich and notifications!

ui screenshot

possible todo

  • notifications in UI (?)
  • contact locations to get an info of which vaccine is in use there (?)
  • store/show statistics about slots per day etc
  • automatic SMS login

API

Here is main caching flat api providing appointment data and geo https://vacme.kloud.top/api/v2/locations for UI display.
Example response:

{
  "vaccination_group": "N",
  "last_refresh": 1621085095601,
  "refresh_interval_sec": 250,
  "locations": [
    {
      "name": "Zürich, TopPharm Morgental Apotheke",
      "id": "00d65270-264f-469f-bdac-765d01d2b14c",
      "noFreieTermine": true,
      "latitude": 47.3437185858769,
      "longitude": 8.529828454511142,
      "link": "https://goo.gl/maps/8VFBvGnSGrZJLHW98"
    },
    {
      "name": "_Impfzentrum Wetzikon",
      "id": "fcfae361-7a74-481d-bc6b-e257e1ddb1de",
      "noFreieTermine": false,
      "firstDate": 1623067200000,
      "secondDate": 1625486400000,
      "latitude": 47.31518772182702,
      "longitude": 8.79995562696232,
      "link": "https://goo.gl/maps/J9sD4ByixUrAQaes9"
    },
    .....
  ]
}

noFreieTermine and id fields are propagated from vacme.ch directly.

See parser only api in parser folder.

local deployment

if you want to run it locally, find your REGISTRATION_ID and REFRESH_TOKEN from browser network tab and run:

docker run --rm -it -e REGISTRATION_ID=? -e REFRESH_TOKEN=? golonzovsky/vacme-parser

or run python code directly.

cloud deployment

In case you want to run it in the cloud - sometimes api starts to redirect into captcha. AFAIK once captcha is solved - IP is added, and you can call vacme again.

If you run in k8s - you need to hide your nodes behind NAT. Then you can to solve captcha from behind NAT ip using socks proxy. Example to create local SOCKS proxy from private GKE node:

gcloud beta compute ssh --zone "europe-west6-a" "gke-main-preemptible-e2-medium-3b140cfc-wv1s" --tunnel-through-iap -- -N -p 22 -D localhost:5000

UPD: added all infra code, see https://github.com/golonzovsky/vacme-zurich-parser/tree/main/infrastructure folder. Its terraform definitions of GKE cluster and things around running in GCP.

vacme-zurich-parser's People

Contributors

golonzovsky avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

vacme-zurich-parser's Issues

How to build a local deployment for ARM64?

Hi!

Unfortunately, the golonzovsky/vacme-parser image is only provided for amd64/x86, so my ARM64 machine can't run it. I'm a bit confused how to get the Docker container for backend and frontend running. I built a new container, with the parser Dockerfile, but running the image in a container results in an error:

docker run --rm -it -e REGISTRATION_ID=XXXX -e REFRESH_TOKEN=eyJhbGciOiJI... golonzovsky/vacme-parser:arm64
Traceback (most recent call last):
  File "/app/main.py", line 202, in <module>
    config.load_incluster_config()
  File "/usr/local/lib/python3.9/site-packages/kubernetes/config/incluster_config.py", line 118, in load_incluster_config
    InClusterConfigLoader(
  File "/usr/local/lib/python3.9/site-packages/kubernetes/config/incluster_config.py", line 54, in load_and_set
    self._load_config()
  File "/usr/local/lib/python3.9/site-packages/kubernetes/config/incluster_config.py", line 62, in _load_config
    raise ConfigException("Service host/port is not set.")
kubernetes.config.config_exception.ConfigException: Service host/port is not set.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/main.py", line 204, in <module>
    config.load_kube_config()
  File "/usr/local/lib/python3.9/site-packages/kubernetes/config/kube_config.py", line 792, in load_kube_config
    loader = _get_kube_config_loader(
  File "/usr/local/lib/python3.9/site-packages/kubernetes/config/kube_config.py", line 751, in _get_kube_config_loader
    raise ConfigException(
kubernetes.config.config_exception.ConfigException: Invalid kube-config file. No configuration found.

What am I missing here?

Great tool! Why is the time not set to Zürich time?

  1. Thank you for the great tool!
  2. Why is the time not set to Zürich time?
  3. {"last_refresh":"Mon, 10 May 2021 13:20:25 GMT","locations":[],"refresh_interval_sec":600,"source":"https://github.com/golonzovsky/vacme-zurich-parser","vaccination_group":"N"}

403 forbidden error

Hi @golonzovsky,

I was doing quite the same parsing for be.vacme.ch. So nice that you shared your code! Thanks.

Currently I have some issues with the authentication. Sometimes I get a 403 forbidden error. Did you also notice it? How did you solve it?

Thanks for your help. Cheers from Bern

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.