jlplenio / doctolib-notifier

A tool for automated availability checking and notification for Doctolib appointments of public insurance.
MIT License
1 stars 0 forks source link

IndexError: list index out of range #3

Open hista opened 6 days ago

hista commented 6 days ago

Hi, I tried your script on the French version of doctolib.

poetry install
Creating virtualenv doctolib-notifier-zLYJRmyl-py3.12 in /home/hista/.cache/pypoetry/virtualenvs
Installing dependencies from lock file

Package operations: 5 installs, 0 updates, 0 removals

  - Installing wrapt (1.16.0)
  - Installing deprecated (1.2.14)
  - Installing mss (9.0.1)
  - Installing websockets (12.0)
  - Installing nodriver (0.34)

Installing the current project: doctolib-notifier (0.1.0)
/home/hista/doctolib-notifier/doctolib_notifier does not contain any element

poetry run python main.py
Please paste in the URL of the practice:
https://www.doctolib.fr/dermatologue/bordeaux/pierre-boussault/booking/new-patient?specialityId=6&agenda_ids%5B%5D=52957&selected_slot=2025-01-27T15%3A30%3A00%2B01%3A00&pid=practice-21072&speciality_ids%5B%5D=6&source=searchResult&bookingFunnelSource=skip_profile_from_search
Traceback (most recent call last):
  File "/home/hista/doctolib-notifier/main.py", line 129, in <module>
    DoctolibNotifier().main(url)
  File "/home/hista/doctolib-notifier/main.py", line 115, in main
    practice_name, practice_id, motive_ids, practitioner_id = self.parse_initial_url(initial_url)
                                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hista/doctolib-notifier/main.py", line 22, in parse_initial_url
    practice_id = query_params.get('placeId', [""])[0].split("-")[1]
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range
successfully removed temp profile /tmp/uc_t2p57f7u

Any idea why? Thanks for your kind help :)

jlplenio commented 6 days ago

You did everything correctly. But the URL you provided is missing some parameters, I don't know why. But I already have a smart solution in mind to make it more robust.

hista commented 6 days ago

Do you mean this idea: https://github.com/jlplenio/doctolib-notifier/issues/2 ? It reminds me this other tool which refers to get-request as well: https://github.com/Schlaurens/doctolib-checker/blob/main/README.md

jlplenio commented 6 days ago

Exactly. Maybe I can push an update this weekend. The other script is native python, but not use-friendly.

hista commented 6 days ago

For me the problem is this method supposes to reach a page with a date. Therefore it doesn't work when the practicer has no date to book yet, even a late one.

jlplenio commented 5 days ago

Should work now for you and french doctolib @hista !

hista commented 5 days ago

Unfortunately not yet:

poetry run python main.py
Please paste in the URL of the practice:
https://www.doctolib.fr/dermatologue/bordeaux/pierre-boussault?pid=practice-21072
Traceback (most recent call last):                                                                                                                                                                                                                                                       
  File "/home/hista/doctolib-notifier/main.py", line 107, in <module>                                                                                                                                                                                                                       
    DoctolibNotifier().main(url)                                                                                                                                                                                                                                                         
  File "/home/hista/doctolib-notifier/main.py", line 94, in main                                                                                                                                                                                                                            
    practice_name, practice_id, motive_ids, practitioner_id = self.parse_initial_url(initial_url)                                                                                                                                                                                        
                                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                                                        
  File "/home/hista/doctolib-notifier/main.py", line 24, in parse_initial_url                                                                                                                                                                                                               
    practice_id = query_params.get('placeId', [""])[0].split("-")[1]                                                                                                                                                                                                                     
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^                                                                                                                                                                                                                     
IndexError: list index out of range                                                                                                                                                                                                                                                      
successfully removed temp profile /tmp/uc__5u0w9hj    
jlplenio commented 5 days ago

The problem lies with your URL. You have to navigate to the end of an offer, where it says that there are currently no appointments available. If you give the tool an URL to a page before that, it is not sure which offer you want to search for.

hista commented 5 days ago

Sorry that makes sense, it works now, thanks! If I may suggest some ideas: