Script to automatically book a vaccine slot on Doctolib for today or tomorrow, following rules from the French Government.

Overview

DOCTOSHOTGUN

This script lets you automatically book a vaccine slot on Doctolib for today or tomorrow, following rules from the French Government.

Python dependencies

  • woob
  • cloudscraper
  • dateutil
  • termcolor
  • playsound

How to use it

Install dependencies:

pip install -r requirements.txt

Run:

./doctoshotgun.py <city> <email> [password]

Optional arguments:

--center "<center_name>" [--center "<other_center>" …]  : filter centers to only choose one from the provided list
--patient <index>                                       : select patient for which book a slot
--debug                                                 : display debug information

With Docker

Build the image:

docker build . -t doctoshotgun

Run the container:

docker run doctoshotgun <city> <email> [password]

Multiple cities

You can also look for slot in multiple cities at the same time. Cities must be separated by commas:

$ ./doctoshotgun.py <city1>,<city2>,<city3> <email> [password]

Filter on centers

You can give name of centers in which you want specifictly looking for:

$ ./doctoshotgun.py paris [email protected] \
      --center "Centre de Vaccination Covid 19 - Ville de Paris" \
      --center "Centre de Vaccination du 7eme arrondissement de Paris - Gymnase Camou"

Select patient

For doctolib accounts with more thant one patient, you can select patient just after launching the script:

$ ./doctoshotgun.py paris [email protected] PASSWORD
Available patients are:
* [0] Roger Philibert
* [1] Luce Philibert
For which patient do you want to book a slot?

You can also give the patient id as argument:

$ ./doctoshotgun.py paris [email protected] PASSWORD -p 1
Starting to look for vaccine slots for Luce Philibert...

Development

Running tests

 $ pip install -r requirements-dev.txt
 $ pytest test_browser.py
Comments
  • Script won't work with double auth connection

    Script won't work with double auth connection

    English

    As mentioned in issue #37

    When manually signing in you'd have to enter your mail address and password and then would be redirected to https://www.doctolib.fr/sessions/two-factor where you have to enter the 6 digit code you've been sent. When this is done I suppose you get a cookie that allows the server to know if the computer is new or not.

    When executed in the script, after connection it ll try to access a page that require you to be logged in. Which is not the case with double auth thus the error 401 sended by the script

    Français

    Comme mentionné dans l'issue #37

    Si l'on a la double authentification voilà ce qu'il se passe

    Dans une navigation 'normale' on est redirigé vers https://www.doctolib.fr/sessions/two-factor et dans le même temps on reçoit un code à 6 chiffres à saisir sur cette page. https://github.com/rbignon/doctoshotgun/issues/37#issuecomment-848904795

    Ensuite la session peut être accéder grâce à un cookie.

    Or dans le script on est directement dirigé vers une page qui demande d'être connecté et provoque l'erreur 401

    opened by tomkimsour 13
  • missing city if both motive_ids 6970 and 7005

    missing city if both motive_ids 6970 and 7005

    Bonjour,

    Tout d'abord un grand merci pour ton script,

    J'ai essayé de booker un créneau pour Puteaux mais j'ai l'impression que le script n'obtient jamais le centre de la ville dans ses résultats de recherches, alors que je le vois en tête des résultats sur l'url de mon navigateur : https://www.doctolib.fr/vaccination-covid-19/puteaux?ref_visit_motive_ids[]=6970&ref_visit_motive_ids[]=7005

    Et là plus étonnant, si j'inverse les ids 6970/7005 de la première requête de la méthode find_centers, le cabinet est trouvé (Trying to find a slot in Centre de Vaccination Covid-19 de Puteaux).

    Je ne sais pas si je suis très clair, et je ne suis pas très bon en Python, mais peut être qu'il y a une explication derrière...

    opened by MyLordAngus 10
  • Will the script work with the new Doctolib queuing system?

    Will the script work with the new Doctolib queuing system?

    Currently when I run the script I have the following message on loop:

    This may take a few minutes/hours, be patient!
    [2021-11-25 18:44:35]
    No free slots found at selected centers. Trying another round in 5 sec...
    [2021-11-25 18:44:40]
    No free slots found at selected centers. Trying another round in 5 sec...
    [2021-11-25 18:44:45]
    No free slots found at selected centers. Trying another round in 5 sec...
    
    ...
    

    I tried debugging, and saw that the url being requested ends up on a queuing system.

    image

    I guess that if we keep pinging this url, it will always fall back at the back of the queue.

    Maybe fortunately with the new queuing system this script is not needed anymore, let's see.

    opened by zaccharieramzi 8
  • Add support for paged results on centers page

    Add support for paged results on centers page

    The results for e.g. Berlin are returned as a paged list (á 10 items) with a link to the next page. Example

    The script should check every page for an appointment.

    opened by Dreiundzwanzig 7
  • Implement 2-factor authentication during login (by email)

    Implement 2-factor authentication during login (by email)

    This commit handles the case where 2fa is required by the server.

    An email code is requested from the server which can then be entered on the command line to complete the 2fa flow.

    Fixes #37, #46 and #55.

    opened by aduffeck 7
  • Error 401

    Error 401

    Bonjour, Merci beaucoup pour votre travail sur ce projet.

    Je reçois une erreur 401 lors du lancement du script.

    Voici le contenu de mon terminal (avec l'option -d pour debug) : ./doctoshotgun.py -d Paris [email protected] Password: DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): www.doctolib.fr:443 DEBUG:urllib3.connectionpool:https://www.doctolib.fr:443 "GET /sessions/new HTTP/1.1" 200 None INFO:browser:Response saved to 677dad1389174096842e851184a51d4a DEBUG:browser:Unable to handle https://www.doctolib.fr/sessions/new DEBUG:urllib3.connectionpool:https://www.doctolib.fr:443 "POST /login.json HTTP/1.1" 200 None INFO:browser:Response saved to 0e2f596a8ebd4e27949d4743235cc5c5 DEBUG:browser:Handle https://www.doctolib.fr/login.json with LoginPage DEBUG:urllib3.connectionpool:https://www.doctolib.fr:443 "GET /account/master_patients.json HTTP/1.1" 401 None INFO:browser:Response saved to 869a22057d7146148592bdd36c2b2e09 Traceback (most recent call last): File "/Users/Victor/Documents/Programmation/Python/doctoshotgun/./doctoshotgun.py", line 420, in sys.exit(Application().main()) File "/Users/Victor/Documents/Programmation/Python/doctoshotgun/./doctoshotgun.py", line 378, in main patients = docto.get_patients() File "/Users/Victor/Documents/Programmation/Python/doctoshotgun/./doctoshotgun.py", line 207, in get_patients self.master_patient.go() File "/usr/local/lib/python3.9/site-packages/woob/browser/url.py", line 98, in go r = self.browser.location(self.build(**kwargs), params=params, data=data, json=json, method=method, headers=headers or {}) File "/usr/local/lib/python3.9/site-packages/woob/browser/browsers.py", line 911, in location response = self.open(*args, **kwargs) File "/usr/local/lib/python3.9/site-packages/woob/browser/browsers.py", line 898, in open return super(PagesBrowser, self).open(callback=internal_callback, *args, **kwargs) File "/usr/local/lib/python3.9/site-packages/woob/browser/browsers.py", line 790, in open return super(DomainBrowser, self).open(req, *args, **kwargs) File "/usr/local/lib/python3.9/site-packages/woob/browser/browsers.py", line 531, in open response = self.session.send(preq, File "/Users/Victor/Documents/Programmation/Python/doctoshotgun/./doctoshotgun.py", line 42, in send return callback(self, resp) File "/usr/local/lib/python3.9/site-packages/woob/browser/browsers.py", line 527, in inner_callback self.raise_for_status(response) File "/usr/local/lib/python3.9/site-packages/woob/browser/browsers.py", line 560, in raise_for_status raise ClientError(http_error_msg, response=response) woob.browser.exceptions.ClientError: 401 Client Error: Unauthorized

    Je suis sur Mac OS X. Avez-vous une idée de ce qui pourrait causer le problème ?

    opened by Dyze95 7
  • Semble non compatible avec windows

    Semble non compatible avec windows

    Lorsque je lance: "doctoshotgun.py paris username_email" de mon environemment venv, j'obtiens l'erreur suivante: " from dateutil.parser import parse as parse_date ModuleNotFoundError: No module named 'dateutil' " si je lance la commande du "./doctoshotgun.py paris username_email", l'erreur est: "'.' is not recognized as an internal or external command, operable program or batch file. " Comment faire fonctionner ce programme sous windows? Merci

    opened by nono-london 7
  • ('525 Server Error: ',)

    ('525 Server Error: ',)

    Since yesterday, I get the following error after a few minutes:

    An unexpected exception of type ServerError occurred. Arguments: ('525 Server Error: ',) root@doctolib:/doctolib#

    Do u have any ideas regarding this issue?

    Best Tn

    opened by tinom86 6
  • Affiliation avec plusvitemadose.fr ?

    Affiliation avec plusvitemadose.fr ?

    Bonjour,

    Il semble que le site "plusvitemadose.fr" (archive) propose une offre "shotgun" pour 25€

    Est-ce affilié a doctoshotgun vu la proximité du nom ?

    opened by Saruspete 6
  • try/except blocks for connection error to prevent script from stopping

    try/except blocks for connection error to prevent script from stopping

    To prevent the script from stopping during times of poor connectivity, we catch any ConnectionError or similar and retry the current step after 60 seconds.

    opened by rjkerrison 6
  • Manage Diacritic in cities names

    Manage Diacritic in cities names

    Manage characters like é à è on cities names... This char should be omited on doctolib URL but are presents on cities names in the json. Exemple : Arès

    I didn't find how to be able to use town with - and/or ' char (like Saint-Médard-en-Jalles or Villenave-d'Ornon)

    opened by cvermot 6
  • I keep getting an exception of type KeyError

    I keep getting an exception of type KeyError

    Hello,

    I am trying to book a slot for a second dose only and I keep getting the same error. Here's the stack :

    found!
      ├╴ Best slot found: Fri Jan  7 14:25:00 2022
    2022-01-06 17:41:20,002:DEBUG:urllib3.connectionpool::connectionpool.py:452:_make_request https://www.doctolib.fr:443 "POST /appointments.json HTTP/1.1" 200 None
    2022-01-06 17:41:20,024:INFO:browser::browsers.py:369:save_response Response saved to 04a310d87fe04418a83bdce601761df3
    2022-01-06 17:41:20,024:DEBUG:browser::browsers.py:880:internal_callback Handle https://www.doctolib.fr/appointments.json with AppointmentPage
    2022-01-06 17:41:20,209:DEBUG:urllib3.connectionpool::connectionpool.py:452:_make_request https://www.doctolib.fr:443 "GET /appointments/3205542638-BAh7CEkiCGdpZAY6BkVUSSI1Z2lkOi8vZG9jdG9saWIvQXBwb2ludG1lbnQvMzIwNTU0MjYzOD9leHBpcmVzX2luBjsAVEkiDHB1cnBvc2UGOwBUSSIMZGVmYXVsdAY7AFRJIg9leHBpcmVzX2F0BjsAVDA=--2837adf8a7ae436192be6729ced96560a44c206c/edit.json HTTP/1.1" 200 None
    2022-01-06 17:41:20,224:INFO:browser::browsers.py:369:save_response Response saved to f7cc04934ccc4a96be6425cb5b9a7b5f
    2022-01-06 17:41:20,240:DEBUG:browser::browsers.py:880:internal_callback Handle https://www.doctolib.fr/appointments/3205542638-BAh7CEkiCGdpZAY6BkVUSSI1Z2lkOi8vZG9jdG9saWIvQXBwb2ludG1lbnQvMzIwNTU0MjYzOD9leHBpcmVzX2luBjsAVEkiDHB1cnBvc2UGOwBUSSIMZGVmYXVsdAY7AFRJIg9leHBpcmVzX2F0BjsAVDA=--2837adf8a7ae436192be6729ced96560a44c206c/edit.json with AppointmentEditPage
      ├╴ Booking for NAME_REDACTED...
    2022-01-06 17:41:20,425:DEBUG:urllib3.connectionpool::connectionpool.py:452:_make_request https://www.doctolib.fr:443 "GET /appointments/3205542638-BAh7CEkiCGdpZAY6BkVUSSI1Z2lkOi8vZG9jdG9saWIvQXBwb2ludG1lbnQvMzIwNTU0MjYzOD9leHBpcmVzX2luBjsAVEkiDHB1cnBvc2UGOwBUSSIMZGVmYXVsdAY7AFRJIg9leHBpcmVzX2F0BjsAVDA=--2837adf8a7ae436192be6729ced96560a44c206c/edit.json?master_patient_id=86177620 HTTP/1.1" 200 None
    2022-01-06 17:41:20,441:INFO:browser::browsers.py:369:save_response Response saved to 8b5a663a48cc4a0eab4e77dc319a2ee2
    2022-01-06 17:41:20,456:DEBUG:browser::browsers.py:880:internal_callback Handle https://www.doctolib.fr/appointments/3205542638-BAh7CEkiCGdpZAY6BkVUSSI1Z2lkOi8vZG9jdG9saWIvQXBwb2ludG1lbnQvMzIwNTU0MjYzOD9leHBpcmVzX2luBjsAVEkiDHB1cnBvc2UGOwBUSSIMZGVmYXVsdAY7AFRJIg9leHBpcmVzX2F0BjsAVDA=--2837adf8a7ae436192be6729ced96560a44c206c/edit.json?master_patient_id=86177620 with AppointmentEditPage
    An unexpected exception of type KeyError occurred. Arguments:
    ('appointment',)
    Traceback (most recent call last):
      File "C:\Users\etien\Documents\doctoshotgun\doctoshotgun.py", line 912, in main
        if docto.try_to_book(center, vaccine_list, start_date, end_date, excluded_weekdays, args.only_second, args.only_third, args.dry_run, args.confirm):
      File "C:\Users\etien\Documents\doctoshotgun\doctoshotgun.py", line 410, in try_to_book
        if self.try_to_book_place(profile_id, motive_id, practice_id, agenda_ids, vac_name.lower(), start_date, end_date, excluded_weekdays, only_second, only_third, dry_run, confirm):
      File "C:\Users\etien\Documents\doctoshotgun\doctoshotgun.py", line 536, in try_to_book_place
        for field in self.page.get_custom_fields():
      File "C:\Users\etien\Documents\doctoshotgun\doctoshotgun.py", line 210, in get_custom_fields
        for field in self.doc['appointment']['custom_fields']:
    KeyError: 'appointment'
    

    Do you have any idea of where it can come from ?

    Thanks in advance

    opened by Tylones 0
  • Add support for pfizer for kids (5 to 11yo)

    Add support for pfizer for kids (5 to 11yo)

    Unless I missed it, I do not see how to use doctoshotgun to book a vaccine slot for a kid (5 to 11yo) in France.

    I'd be happy to send a PR, but I'm not sure how to retrive the code for this specific vaccine (to add in DoctolibFR).

    opened by douardda 1
  • [WIP] doctoshotgun is now an installable python module

    [WIP] doctoshotgun is now an installable python module

    In order to use doctoshotgun as a library in another project I'm currently writing (doctoshotgun_gui, a multiplatform frontend of doctoshotgun!), I split the script into a real python module, which can be imported.

    Everything is not done yet, but I would be interested to get reviews.

    TODO:

    • [ ] fix tests
    • [ ] change Dockerfile
    • [ ] change README
    • [ ] try to remove all calls to log() in doctoshotgun.doctolib
    opened by rbignon 0
  • Fails to decode JSON on start.

    Fails to decode JSON on start.

    Since this morning the script isn’t able to start. Please, find below the error I get:

    ~/doctoshotgun$ ./doctoshotgun.py fr brest [email protected]
    Password: 
    
    Traceback (most recent call last):
      File "/home/user/doctoshotgun/./doctoshotgun.py", line 949, in <module>
        sys.exit(Application().main())
      File "/home/user/doctoshotgun/./doctoshotgun.py", line 744, in main
        docto.load_state(self.load_state())
      File "/home/user/doctoshotgun/./doctoshotgun.py", line 662, in load_state
        state = json.load(fp)
      File "/usr/lib/python3.9/json/__init__.py", line 293, in load
        return loads(fp.read(),
      File "/usr/lib/python3.9/json/__init__.py", line 346, in loads
        return _default_decoder.decode(s)
      File "/usr/lib/python3.9/json/decoder.py", line 337, in decode
        obj, end = self.raw_decode(s, idx=_w(s, 0).end())
      File "/usr/lib/python3.9/json/decoder.py", line 355, in raw_decode
        raise JSONDecodeError("Expecting value", s, err.value) from None
    json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
    
    opened by PierreLeGuen 3
  • adding automatic handling of vaccine age restrictions

    adding automatic handling of vaccine age restrictions

    I accidentally booked a Moderna vaccine not knowing I was underage for it. To save others from making the same error (and potentially wasting doses), I've added support to automatically reflect those restrictions.

    At time of writing, ameli.fr's Qui peut se faire vacciner, quand et comment? states that:

    • "Le vaccin Moderna n'est cependant ouvert qu'aux personnes âgées de 30 ans et plus."
    • "Les adolescents âgés de 12 à 17 ans peuvent se faire vacciner contre le Covid-19 avec le vaccin Pfizer." 
    opened by rjkerrison 1
Owner
Romain Bignon
Romain Bignon
VaccineAlarm is a simple python script that allows user to get notified when their desired vaccine doses are available at vaccine centers near them.

Introduction VaccineAlarm is a simple python script that allows user to get notified when their desired vaccine doses are available at vaccine centers

Ankit Tripathi 5 Nov 26, 2021
CoWIN Vaccination slot booking telegram bot with auto captcha resolver & alerting feature.Now, never miss a slot.

COWIN VACCINATION SLOT AUTO BOOKING (Bot with captcha solving & alerting capabilities. Never miss the vaccine slot.) June-10-2021/ 0030 hrs: 23 succes

Shashank Bafna 17 Nov 12, 2022
Telegram Bot to check covid vaccine slot availability on CoWin site

Cowin Assist Telegram Bot Check the bot here @cowinassistbot. This is a simple Telegram bot to Check slots availability Get an alert when slots become

null 32 Jun 21, 2022
Get Notified about vaccine availability in your location on email & sms ✉️! Vaccinator Octocat tracks & sends personalised vaccine info everday. Go get your shot ! 💉

Vaccinater Get Notified about vaccine availability in your location on email & sms ✉️ ! Vaccinator Octocat tracks & sends personalised vaccine info ev

Mayukh Pankaj 6 Apr 28, 2022
A simple bot that looks for names and cpfs in the vaccination list made available by the government Fortaleza - CE

A simple bot that looks for names and cpfs in the vaccination list made available by the government Fortaleza - CE

Breno Aquino 1 Dec 21, 2021
Automatically searching for vaccine appointments

Vaccine Appointments Automatically searching for vaccine appointments Usage To copy this package, run: git clone https://github.com/TheIronicCurtain/v

null 58 Apr 13, 2021
A stock information collector and parser for Taiwan and US market. Automatically send LINE message if the pre-defined rules are triggered.

agastock 開發動機 就在海運飆漲的2021年7月,差點跪在地上喜迎財富自由的當下,EPS超高好消息不斷的長榮竟然套在202元一去不回,有圖有真相(哭) 忽然體會到追高殺低不是辦法,魯蛇我得靠邏輯分析也能出頭天,經過三個月無數個不出門的周末,產出簡單的爬蟲和分析工具。 上過金融研訓院的量化交易

Gavin Lee 12 Nov 16, 2022
This bot will pull a stream of tweets based on rules you set and automatically reply to them.

Twitter reply bot This bot will pull a stream of tweets based on rules you set and automatically reply to them. I built this bot in order to help comb

Brains 1 Feb 13, 2022
This very basic script can be used to automate COVID-19 vaccination slot booking on India's Co-WIN Platform.

COVID-19 Vaccination Slot Booking Script This very basic CLI based script can be used to automate covid vaccination slot booking on Co-WIN Platform. I

null 605 Dec 14, 2022
Python script to decode the EU Covid-19 vaccine certificate

vacdec Python script to decode the EU Covid-19 vaccine certificate This script takes an image with a QR code of a vaccine certificate as the parameter

Hanno Böck 244 Nov 30, 2022
Weather_besac is a French twitter bot that tweet the weather of the city of Besançon in Franche-Comté in France every day at 8am and 4pm.

Weather Bot Besac Weather_besac is a French twitter bot that tweet the weather of the city of Besançon in Franche-Comté in France every day at 8am and

Rgld_ 1 Nov 15, 2021
Tracker to check the covid shot slot availability in India and send mobile alerts via Twilio Messaging Service.

Cowin-Slot-Tracker Tracker to check the covid vaccine slot availability in India and send mobile notifications through Twilio Messaging Service. Requi

invalid username 27 Nov 12, 2022
Telegram bot that search for the classrooms status of the chosen day and then return all the free classrooms using your preferred time slot

Aule Libere Polimi Since the PoliMi site no longer allows people to search for free classrooms this bot was necessary! It simply search for the classr

Daniele Ferrazzo 16 Nov 9, 2022
Bot to notify when vaccine appointments are available

Vaccine Watch Bot to notify when vaccine appointments are available. Supports checking Hy-Vee, Walgreens, CVS, Walmart, Cosentino's stores (KC), and B

Peter Carnesciali 37 Aug 13, 2022
A telegram bot that messages you available vaccine appointments in the Veneto region

Serenissimo, domande frequenti Chi sei? Sono Alberto Granzotto, libero professionista a Berlino. Mi occupo di servizi software, privacy, decentralizza

vrde 31 Sep 30, 2022
Pls give vaccine.

Pls Give Vaccine A script to spam yourself with vaccine notifications. Explore the docs » View Demo · Report Bug · Request Feature Table of Contents A

Rohan Mukherjee 3 Oct 27, 2021
Light weight Scripts and Apps for checking availability of Covid Vaccines in India. Notifies when vaccine becomes avialable in your area.

vaccine-checker Light weight Scripts and Apps for checking availability of Covid Vaccines in India. Notifies when vaccine becomes avialable in your ar

Abishek V Ashok 8 Jun 16, 2021
A Telegram Bot which notifies the user when a vaccine is available on CoWin Platform.

Cowin Vaccine Availability Notifier Telegram Bot A bot that notifies the available vaccines at given district in realtime. Introduction • Requirements

Arham Shah 7 Jul 31, 2021
Telegram bot for downloading covid-19 vaccine certificate

cowin-certificate-bot This is the source code of @cowincertbot, A telegram bot inspired by the whatsapp bot implementation of indian government for co

ArUn Pt 30 Oct 7, 2022