Giter VIP home page Giter VIP logo

medihunter's Introduction

medihunter

ko-fi

Narzędzia służy do automatycznego wyszukiwania wizyt u lekarzy. Szczególnie przydaje się gdy wizyty są trudno dostępne ;)

Działa z pythonem w wersji 3.6+

Wstęp

Dostępne są dwie wersje skryptu

  • medihunter_pushover.py - ma funkcje powiadomień pushover, możliwość wyszukiwania kilku klinik i kilku specjalistów jednocześnie. Kod wymaga refaktoru i w związku z tym nie będzie rozwijany. Z czasem planuje go usunąć.
  • medihunter.py - tu dodawane są nowe funkcjonalności. Na chwilę obecną (2021-07-11) można ustawić powiadomienia pushover, w telegramie i przez xmpp.

Instalacja

Aktywujemy virtualenva (opcjonalnie choć zalecane)

source /path/to/my/virtualenv/bin/activate

lub w Windows cmd ze środowiskiem wirtualnym utworzonym biblioteką venv

SourceToVirtEnv\Scripts\activate.bat

Przechodzimy do katalogu ze źródłem i odpalamy

pip install --editable .

Od teraz mamy dostępną w virtualenvie komendę: medihunter

Jeśli nie chcemy być za każdym razem pytani o login i hasło i/lub nie chcemy podawać ich jawnie w terminalu poprzez --user login --password hasło to możemy zapisać je w pliku .env:

MEDICOVER_USER=login
MEDICOVER_PASS=hasło

Najprościej skopiować przykładowy plik .env.example z głównego katalogu jako .env i uzupełnić w nim dane.

Dostępne subkomendy

show-params

Gdy wyszukujemy wizyty musimy podać miasto, placówkę medyczną, specjalizację (jaki to ma być lekarz), identyfikator lekarza (możliwość wybrania konkretnego lekarza), datę wizyty (wizyta zacznie się nie wcześniej niż ta data). Każdy z tych parametrów (z wyjątkiem daty) ma przypisany nr id. Żeby go poznać używamy do tego komendy show-params.

id miast

medihunter show-params -f region

id specjalizacji

medihunter show-params -f specialization -r 204

find-appointment

Poszukajmy endokrynologa

medihunter find-appointment -s 27962

Oczywiście znalezienie wizyty do endokrynologa nie jest takie proste, więc ustawmy żeby wyszukiwarka sprawdzała czy jest coś dostępne co 5 minut

medihunter find-appointment -s 27962 -i 5

a może chcemy poszukać konkretnych endokrynolgów o ID: 12345 i 0987? tylko w medicover_pushover.py

medihunter find-appointment -s 27962 -o 12345 -o 0987

a może po prostu szukamy dowolnego internisty w przychodniach blisko nas w Atrium i na Prostej? tylko w medicover_pushover.py

medihunter find-appointment -s 9 -c 174 -c 49088

a co jeśli chcemy znaleźć wizytę u dowolnego ortopedy w Trójmieście w przeciągu następnych dwóch tygodni a nie za miesiąc? bez daty rozpoczęcia nie działa

medihunter find-appointment -s 163 -d 2021-12-19 -f 2022-12-31 -r 200

Lub można dodać bezpośrednio do Crontaba jak poniżej wpis w cronie działa tylko z medicover_pushover.py

  • będzie uruchamiany między 6tą a 23cią co 5 minut
  • -s - szuka Ortopedy dla dorosłych
  • -c 174 -c 6896 tylko w centrum Warszawa Atrium i Warszawa Inflancka Będzie korzystał z podanych parametrów użytkownika Medicoveru i Pushover do wysyłania powiadomień
  • crontab zapisze logi w /var/log/medihunter.log
*/5 6-23 * * * /usr/bin/python3.7 /home/user/medihunter.py find-appointment -s 163 -c 174 -c 6896 --user MEDICOVER_USER --password MEDICOVER_PASS --pushover_msgtitle 'Ortopeda Centrum' --pushover_token PUSHOVER_TOKEN --pushover_user PUSHOVER_USER >> /var/log/medihunter.log 2>&1

my-plan

Ściąga i zapisuje dostępne usługi wraz z informacjami na temat tego czy są dostępne w ramach wykupionego pakietu, a jeśli nie to czy mamy na nie jakieś zniżki. Niektóre usługi mają limity, to też powinno być tu widoczne. Plik wynikowy ma format tsv (Tab-separated_values). Przykład użycia:

medihunter my-plan --user mylogin --password mypassword

Wyświetlanie pomocy

Ogólna pomoc

medihunter --help

Poszczególne subkomendy

medihunter find-appointment --help
medihunter show-params --help

Powiadomienia Pushover

dotyczy medicover_pushover.py

Poprzez podanie parametrów do powiadomień Poshover https://pushover.net/ możliwe jest przekazywanie powiadomień na wizytę bezpośrednio do aplikacji. Należy podać minimalnie parametry --pushover_token oraz --pushover_user

Domyślne ustawienia

show-params

domyślnie -f jest ustawiony na specialization

find-appointment

TODO: Poniższe opcje aktualne tylko dla medihunter_pushover.py

opcja domyślna wartość
-r, --region Warszawa
-b, --bookingtype 2, Typ wizyty 2 = Konsultacja (domyślnie), 1 = Badanie diagnostyczne
-s, --specialization brak Specjalizacja, podać w przypadku gdy Typ wizyty to Konsultacja (bookingtype = 2 domyślnie)
-e, --service brak, Typ/identyfikator usługi, podać w przypadku gdy Typ wizyty to usługa (bookingtype = 1), działa analogicznie do specjalizacji
-c, --clinic wszystkie jakie są w regionie/mieście, można użyć parametru wielokrotnie w celu szukania wizyt w konkretnych klinikach
-o, --doctor wszyscy lekarze, można użyć parametru wielokrotnie w celu sprawdzenie kilku lekarzy
-d, --start-date data bieżąca (format: YYYY-mm-dd)
-f, --end-date brak (format: YYYY-mm-dd), dostępna tylko w medihunter.py
-a, --start-time "0:00" (format: hh:mm), dostępna tylko w medihunter.py
-g, --end-time "23:59" (format: hh:mm), dostępna tylko w medihunter.py
-j, --days-ahead 1 = pokazuje wizyty dla pierwszego znalezionego dnia, dostępna tylko w medihunter.py
-i, --interval brak
--disable-phone-search brak, Pozwala pominąć wizyty telefoniczne w wyszukiwaniu, dostępna tylko w medihunter.py
--pushover_token brak, Pushover Application Token
--pushover_user brak, Pushover user Token
--pushover_device brak, None nazwa device w Pushover domyślnie pusta=wszystkie
--pushover_msgtitle brak - prefix dodawany przed tytułem powiadomienia
-t, --notification-title brak, dostępna tylko w medihunter.py, wspierana tylko przez Pushover, Telegram i Gotify

Pushbullet w medihunter.py

Żeby działały powiadomienia pushbullet trzeba zrobić eksport (wartości ustawiamy swoje):

# bash
export NOTIFIERS_PUSHBULLET_TOKEN=avykwnqc8ohyk73mo1bsuggsm3r4qf

lub

# fish
set -x NOTIFIERS_PUSHBULLET_TOKEN avykwnqc8ohyk73mo1bsuggsm3r4qf

Teraz możemy wyszukać wizyty np. tak:

medihunter find-appointment -n pushbullet -r 204 -s 4798 --user 00000 --password psw1234 -i 1 -d 2019-05-15

Pushover w medihunter.py

Żeby działały powiadomienia pushover trzeba zrobić eksport (wartości ustawiamy swoje):

# bash
export NOTIFIERS_PUSHOVER_TOKEN=avykwnqc8ohyk73mo1bsuggsm3r4qf
export NOTIFIERS_PUSHOVER_USER=s4g1zoewbzseogp4knrapx23k9yi95

lub

# fish
set -x NOTIFIERS_PUSHOVER_TOKEN avykwnqc8ohyk73mo1bsuggsm3r4qf
set -x NOTIFIERS_PUSHOVER_USER s4g1zoewbzseogp4knrapx23k9yi95

Teraz możemy wyszukać wizyty np. tak:

medihunter find-appointment -n pushover -r 204 -s 4798 --user 00000 --password psw1234 -i 1 -d 2019-05-15

Telegram w medihunter.py

Musimy utworzyć bota do powiadomień i kanał na który będą przesyłane powiadomienia. Szczegóły jak to zrobić można znaleźć pod adresem https://core.telegram.org/bots

Jak już mamy to gotowe to wystarczy zrobić eksport dwóch zmiennych (wartości ustawiamy swoje):

# bash
export NOTIFIERS_TELEGRAM_CHAT_ID=avykwnqc8ohyk73mo1bsuggsm3r4qf
export NOTIFIERS_TELEGRAM_TOKEN=740885363:AdFRNFTIFTc4hC1flAuXE-dyik_Udm6Ma3o

lub

# fish
set -x NOTIFIERS_TELEGRAM_CHAT_ID avykwnqc8ohyk73mo1bsuggsm3r4qf
set -x NOTIFIERS_TELEGRAM_TOKEN 740885363:AdFRNFTIFTc4hC1flAuXE-dyik_Udm6Ma3o

lub w Windows z venv

set NOTIFIERS_TELEGRAM_CHAT_ID=avykwnqc8ohyk73mo1bsuggsm3r4qf
set NOTIFIERS_TELEGRAM_TOKEN=740885363:AdFRNFTIFTc4hC1flAuXE-dyik_Udm6Ma3o

Teraz możemy wyszukać wizyty i otrzymać notyfikacje w Telegramie:

medihunter find-appointment -r 204 -s 4798 --user 00000 --password psw1234 -i 1 -d 2019-05-22 -n telegram

XMPP w medihunter.py

Musimy posiadać 2 zarejestrowane konta XMPP:

  • pierwsze do wysyłania wiadomości, w przypadku odnalezienia wizyt zgodnych z zadanymi kryteriami wyszukiwania,
  • drugie do odbierania wiadomości z powiadomieniami, na którym będziemy zalogowani w dowolnym kliencie obsługującym XMPP (np. na komputerze/urządzeniu mobilnym).

Eksportujemy nazwy obu kont XMPP i hasło logowania do pierwszego z kont (wartości ustawiamy swoje):

# bash
export NOTIFIERS_XMPP_JID='[email protected]'
export NOTIFIERS_XMPP_PASSWORD='haslo_nadawcy_powiadomien'
export NOTIFIERS_XMPP_RECEIVER='[email protected]'

lub

# fish
set -x NOTIFIERS_XMPP_JID '[email protected]'
set -x NOTIFIERS_XMPP_PASSWORD 'haslo_nadawcy_powiadomien'
set -x NOTIFIERS_XMPP_RECEIVER '[email protected]'

Teraz możemy wyszukać wizyty i otrzymać notyfikacje poprzez XMPP:

medihunter find-appointment -r 204 -s 4798 --user 00000 --password psw1234 -i 1 -d 2019-05-22 -n xmpp

Gotify w medihunter.py

Gotify jest prostym serwisem do wysyłania powiadomień typu push głównie na urządzenia z systemem Android. Różni się od innych tego typu aplikacji, że jest w pełni open source oraz do przeznaczony do hostowania na własnym serwerze.

W celu skorzystania z tej metody powiadomień musimy ustawić kilka zmiennych środowiskowych:

# bash
export GOTIFY_TOKEN=AbCDeFg2yvapfPA
export GOTIFY_HOST=https://gotify.my-server.com

lub

# fish
set -x GOTIFY_TOKEN 'AbCDeFg2yvapfPA'
set -x GOTIFY_HOST 'https://gotify.my-server.com'

lub w Windows z venv

set GOTIFY_TOKEN=AbCDeFg2yvapfPA
set GOTIFY_HOST=https://gotify.my-server.com

Istnieje również opcjonalna zmienna GOTIFY_PRIORITY która pozwala na ustawienie priorytetu powiadomienia (domyślnie 5).

Teraz możemy wyszukać wizyty i otrzymać notyfikacje poprzez Gotify:

medihunter find-appointment -r 204 -s 4798 --user 00000 --password psw1234 -i 1 -d 2019-05-22 -n gotify

Docker

Aby uruchomić aplikację w kontenerze należy w pierwszej kolejności zbudować obraz

docker build -t medihunter .

Następnie uruchamiamy kontener używając komendę run

docker run -it medihunter find-appointment --user 00000 --password psw1234 -r 204 -s 4798

Możliwe jest także użycie zmiennych środowiskowych lub pliku .env

docker run -it  -e MEDICOVER_USER=00000 -e MEDICOVER_PASS=psw1234 medihunter find-appointment -r 204 -s 4798d

docker run -it --env-file=.env medihunter find-appointment -r 204 -s 4798

medihunter's People

Contributors

apqlzm avatar arsenictangerine avatar darekdesu avatar dependabot[bot] avatar guesswhy avatar jacekjaros avatar jaroslawjarmolowicz-tomtom avatar justaphrog avatar krzysztofkarol avatar linoskoczek avatar mek-x avatar melroy89 avatar mlewand3 avatar nowszymon avatar pewu avatar piomar123 avatar piosk7 avatar rafal-krypa avatar tjozwik avatar wojtekk78 avatar

Stargazers

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

Watchers

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

medihunter's Issues

My-appointments is not intuitive

My-appointments is dumping everything to file and nothing gets printed on screen. I would like to change it so it only shows future visits on screen.

Fajny pomysł. Ale coś mi nie chce działać

Witaj

Na Windows 10 z Python 2.7 mam tak:

Traceback (most recent call last):
  File "C:\Python27\medihunter\Scripts\medihunter-script.py", line 11, in <module>
    load_entry_point('medihunter', 'console_scripts', 'medihunter')()
  File "c:\python27\medihunter\lib\site-packages\pkg_resources\__init__.py", line 489, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "c:\python27\medihunter\lib\site-packages\pkg_resources\__init__.py", line 2793, in load_entry_point
    return ep.load()
  File "c:\python27\medihunter\lib\site-packages\pkg_resources\__init__.py", line 2411, in load
    return self.resolve()
  File "c:\python27\medihunter\lib\site-packages\pkg_resources\__init__.py", line 2417, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "c:\python27\medihunter\medihunter.py", line 42
    f'(iteration: {counter}) No results found', fg='yellow'))

Pozdrawiam serdecznie

`JSONDecodeError: Expecting value` after some while

I got a JSONDecodeError: Expecting value error followed by a crash after some 100+ iterations. I possibly got throttled, since I set up a relative short interval. Nonetheless, it would be nice if the tool:

  1. console-printed the top n lines of the JSON it actually received
  2. sent a regular notification about the error
  3. maybe increased an interval gradually until it received a valid JSON again, instead of quitting cowardly

Traceback I got:

Traceback (most recent call last):
  File "/home/medicover/medihunter/venv/lib/python3.10/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.10/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)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/medicover/medihunter/venv/bin/medihunter", line 33, in <module>
    sys.exit(load_entry_point('medihunter', 'console_scripts', 'medihunter')())
  File "/home/medicover/medihunter/venv/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/medicover/medihunter/venv/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/medicover/medihunter/venv/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/medicover/medihunter/venv/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/medicover/medihunter/venv/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/medicover/medihunter/medihunter.py", line 170, in find_appointment
    found_appointments = med_session.search_appointments(
  File "/home/medicover/medihunter/medicover_session.py", line 304, in search_appointments
    appointments = self._parse_search_results(result)
  File "/home/medicover/medihunter/medicover_session.py", line 223, in _parse_search_results
    result = result.json()
  File "/home/medicover/medihunter/venv/lib/python3.10/site-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

My Plan error

When:

$ medihunter my-plan

That:
Logged in as XXXX
Traceback (most recent call last):
File "/usr/local/bin/medihunter", line 11, in
load_entry_point('medihunter', 'console_scripts', 'medihunter')()
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1130, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/home/parallels/medicover/medihunter/medihunter.py", line 244, in my_plan
plan = med_session.get_plan()
File "/home/parallels/medicover/medihunter/medicover_session.py", line 345, in get_plan
drop_down_options = drop_down.find_all("option")
AttributeError: 'NoneType' object has no attribute 'find_all'

Any idea ?

Medihunter do not search for phone visits

Im not sure what has changed but from some time this script do not shows phone visit. Actually do not find any appointments because finding stationary visits is almost impossible :)
I think that it has something in common with visitType=0 parameter in Medicover web page address .
When visitType=0 is set in web page , it do not search for phone visit, when its set to visitType=all you can search phone visit.
I think that in Medihunter it is -b, --bookingtype parameter, but it cannot be set to all...
Im running this command:
medihunter find-appointment -s $spec -r 204 --user $MEDICOVER_USER --password $MEDICOVER_PASS
where $spec is specialization with phone visit type (like Internista porada telefonicza)

Error when installing python-pushover on python 3.11

Steps to reproduce

$ python3.11 -V
Python 3.11.2

$ python3.11 -m venv venv

$ source venv/bin/activate

$ pip install --editable .
Obtaining file:///home/r.safin/projects/medihunter
  Preparing metadata (setup.py) ... done
Collecting fake-useragent
  Using cached fake_useragent-1.1.1-py3-none-any.whl (50 kB)
Collecting click
  Using cached click-8.1.3-py3-none-any.whl (96 kB)
Collecting requests
  Using cached requests-2.28.2-py3-none-any.whl (62 kB)
Collecting beautifulsoup4
  Using cached beautifulsoup4-4.11.2-py3-none-any.whl (129 kB)
Collecting python-pushover
  Using cached python-pushover-0.4.tar.gz (19 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [1 lines of output]
      error in python-pushover setup command: use_2to3 is invalid.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Working workaround here, older version of setuptools must be used:
Thibauth/python-pushover#42 (comment)

pip install setuptools==57.5.0
pip install --editable .

ModuleNotFoundError: No module named 'notifiers'

Po odpaleniu komendy medihunter dostaję taki błąd:

Traceback (most recent call last):
File "/usr/local/bin/medihunter", line 11, in
load_entry_point('medihunter', 'console_scripts', 'medihunter')()
File "/usr/local/lib/python3.7/site-packages/pkg_resources/init.py", line 489, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python3.7/site-packages/pkg_resources/init.py", line 2793, in load_entry_point
return ep.load()
File "/usr/local/lib/python3.7/site-packages/pkg_resources/init.py", line 2411, in load
return self.resolve()
File "/usr/local/lib/python3.7/site-packages/pkg_resources/init.py", line 2417, in resolve
module = import(self.module_name, fromlist=['name'], level=0)
File "/Users/michal/Projekty/medihunter/medihunter.py", line 14, in
from medihunter_notifiers import pushover_notify
File "/Users/michal/Projekty/medihunter/medihunter_notifiers.py", line 1, in
from notifiers import get_notifier
ModuleNotFoundError: No module named 'notifiers'

Missing retry after HTTPError: 500 Server Error

I receive this error pretty often after +- 200–400 iterations:

Traceback (most recent call last):
  File "/home/sos/.local/bin/medihunter", line 11, in <module>
    load_entry_point('medihunter', 'console_scripts', 'medihunter')()
  File "/usr/lib/python3/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/mnt/c/Users/sos/medihunter/medihunter.py", line 172, in find_appointment
    found_appointments = med_session.search_appointments(
  File "/mnt/c/Users/sos/medihunter/medicover_session.py", line 253, in search_appointments
    self.check_response_correctness(result)
  File "/mnt/c/Users/sos/medihunter/medicover_session.py", line 280, in check_response_correctness
    result.raise_for_status()
  File "/usr/lib/python3/dist-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: https://mol.medicover.pl/api/MyVisits/SearchFreeSlotsToBook?language=pl-PL

This terminate script and I need to rerun them after that

"Remote end closed connection without response" exceptions

I receive this exceptions quite often, after ±300 iterations

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 421, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 416, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.8/http/client.py", line 1347, in getresponse
    response.begin()
  File "/usr/lib/python3.8/http/client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.8/http/client.py", line 276, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 719, in urlopen
    retries = retries.increment(
  File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 400, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/lib/python3/dist-packages/six.py", line 702, in reraise
    raise value.with_traceback(tb)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 421, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 416, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.8/http/client.py", line 1347, in getresponse
    response.begin()
  File "/usr/lib/python3.8/http/client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.8/http/client.py", line 276, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sos/.local/bin/medihunter", line 11, in <module>
    load_entry_point('medihunter', 'console_scripts', 'medihunter')()
  File "/usr/lib/python3/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/mnt/c/Users/sos/medihunter/medihunter.py", line 172, in find_appointment
    found_appointments = med_session.search_appointments(
  File "/mnt/c/Users/sos/medihunter/medicover_session.py", line 245, in search_appointments
    result = self.session.post(
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 581, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 498, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

403 after log-in

Each time I try to do search I get this stacktrace.
Same user/password was used before. For some reason it stopeed working.
Passowrd is correct - just checked that.
medicover_session.py 150 response status is http_403

`
Traceback (most recent call last):
File "medihunter.py", line 282, in
medihunter()
File "/home/emil/medihunter-venv/lib/python3.7/site-packages/click/core.py", line 829, in call
return self.main(*args, **kwargs)
File "/home/emil/medihunter-venv/lib/python3.7/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/home/emil/medihunter-venv/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/emil/medihunter-venv/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/emil/medihunter-venv/lib/python3.7/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "medihunter.py", line 182, in find_appointment
disable_phone_search=disable_phone_search
File "/home/emil/medihunter/medicover_session.py", line 236, in search_appointments
appointments = self._parse_search_results(result)
File "/home/emil/medihunter/medicover_session.py", line 159, in _parse_search_results
result = result.json()
File "/home/emil/medihunter-venv/lib/python3.7/site-packages/requests/models.py", line 900, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib/python3.7/json/init.py", line 348, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.7/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)

`

setup command: use_2to3 is invalid.

Collecting python-pushover (from medihunter==0.1)
  Using cached python-pushover-0.4.tar.gz (19 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [1 lines of output]
      error in python-pushover setup command: use_2to3 is invalid.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

Chyba to jest przyczyna:
Thibauth/python-pushover#42

Wizyty tylko z jednego dnia

Czy aplikacja zwraca tylko wizyty z jednego dnia? Oczywiście tego, który jest najbliżej daty od której się szuka?

Przykładowo jeśli pojawi się dogodny dla mnie termin na 3 stycznia, ale wciąż dostępna jest wizyta na 2 stycznia (godzina mi nie odpowiada) to aplikacja mnie o tym nie poinformuje?

requirements - missing lxml

Error:

# python3 ./medihunter.py my-plan
Logged in
Traceback (most recent call last):
  File "/home/jacek/opt/medihunter/./medihunter.py", line 283, in <module>
    medihunter()
  File "/home/jacek/opt/medihunter/.venv/lib/python3.10/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/jacek/opt/medihunter/.venv/lib/python3.10/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/jacek/opt/medihunter/.venv/lib/python3.10/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/jacek/opt/medihunter/.venv/lib/python3.10/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/jacek/opt/medihunter/.venv/lib/python3.10/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/jacek/opt/medihunter/./medihunter.py", line 234, in my_plan
    plan = med_session.get_plan()
  File "/home/jacek/opt/medihunter/medicover_session.py", line 356, in get_plan
    soup = BeautifulSoup(medical_services_website.content, "lxml")
  File "/home/jacek/opt/medihunter/.venv/lib/python3.10/site-packages/bs4/__init__.py", line 195, in __init__
    raise FeatureNotFound(
bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?

Python version:

#python3 --version
Python 3.10.9

Packages:

pip list
Package        Version
-------------- ---------
appdirs        1.4.4
beautifulsoup4 4.6.3
certifi        2018.4.16
chardet        3.0.4
Click          7.0
fake-useragent 1.1.0
idna           2.7
jsonschema     2.6.0
notifiers      1.0.3
pip            22.3.1
python-dotenv  0.19.2
requests       2.20.1
rfc3987        1.3.8
setuptools     65.6.3
urllib3        1.23
xmpppy         0.6.2

PS.
After lxml install i get error described in #30

Error after login

Cześć,

Pobrałem skrypt i podczas próby uruchomienia dostaję error. Czy masz może pomysł z czego wynika ten error?

Będę wdzięczny za pomoc

Dzięki!

c:\Skrypty\Medihunter>medihunter find-appointment -r Warszawa -s 3
User: ****
Password:
Logged in
Traceback (most recent call last):
File "C:\Python\Scripts\medihunter-script.py", line 11, in
load_entry_point('medihunter', 'console_scripts', 'medihunter')()
File "c:\python\lib\site-packages\click-7.0-py3.7.egg\click\core.py", line 764, in call
return self.main(*args, **kwargs)
File "c:\python\lib\site-packages\click-7.0-py3.7.egg\click\core.py", line 717, in main
rv = self.invoke(ctx)
File "c:\python\lib\site-packages\click-7.0-py3.7.egg\click\core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\python\lib\site-packages\click-7.0-py3.7.egg\click\core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\python\lib\site-packages\click-7.0-py3.7.egg\click\core.py", line 555, in invoke
return callback(*args, **kwargs)
File "c:\skrypty\medihunter\medihunter.py", line 136, in find_appointment
service=service)
File "c:\skrypty\medihunter\medicover_session.py", line 219, in search_appointments
return self._parse_search_results(result)
File "c:\skrypty\medihunter\medicover_session.py", line 151, in _parse_search_results
result = result['items']
KeyError: 'items'

Medihunter started to error: `Unsuccessful logging in`

First of all @apqlzm - thanks for great project:) I use it for long time :)

Today I noticed that medihunter stopped working for me :(

$ /usr/bin/python3 medihunter.py find-appointment -r 205 -s 27160 --user $CARD_S --password $PASS_S
Unsuccessful logging in
marcin@OpenWrt:~/medihunter-old$ 

I tried on 2 accounts both are logging same error, and it was working 3 days ago.

Same issue on second computer.

Was there a change in mediover logic / did they banned medihunter :( ?

Impossible to skip phone "visits"

By default medicover is returning visits over phone in search results. Would be cool to skip them as they are useless when looking for visit with required physical presence.

Docker Support

Przydałoby się dodanie wsparcia dla dockera, żeby nie trzeba było budować aplikacji na lokalnej maszynie.

Invalid login/password causes "no appointments found"

I believe it should be an error.

It looks like the POST request in step 6 of the login process returns a 200 OK HTML page with just an error message somewhere in the middle. The data object is then {}, and login silently proceeds to the end. Then, when you search for appointments with SearchFreeSlotsToBook it'll return a 401/403 (can't remember) and an empty list will be returned from the whole function.

Caused me some pain (especially since you lock your account for 15 minutes every time you input your username/pass wrong 3 times) until I found out I was missing one char from the password in my script, thought it could help someone else (or this could be fixed if someone has the time) - guess it'll involve some soup work.

BTW thanks a lot for this tool 🙏 it's already very useful to me.

Bot crashes if connection error

If I lock or close my laptop then medihunter might crash, because wifi turns off:

requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

Is it possible to not crash and continue run requests? So I have no need to check every time is bot working or not.

Fresh cloned medihunter - error in `pip install --editable .`

I'd same error on previous installation of medihunter so maybe it's worth reporting it here.
Maybe it will help some else with same problems...

In freshly cloned medihunter I've error during installation:

marcin@pc:~/medihunter$ pip install --editable .
Defaulting to user installation because normal site-packages is not writeable
Obtaining file:///home/marcin/medihunter
  Preparing metadata (setup.py) ... done
Collecting appdirs
  Downloading appdirs-1.4.4-py2.py3-none-any.whl (9.6 kB)
Collecting beautifulsoup4
  Downloading beautifulsoup4-4.11.1-py3-none-any.whl (128 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 128.2/128.2 KB 1.2 MB/s eta 0:00:00
Requirement already satisfied: click in /usr/lib/python3/dist-packages (from medihunter==0.1) (8.0.3)
Collecting lxml
  Downloading lxml-4.9.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (6.9 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6.9/6.9 MB 1.2 MB/s eta 0:00:00
Collecting notifiers
  Downloading notifiers-1.3.3-py3-none-any.whl (43 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 44.0/44.0 KB 1.0 MB/s eta 0:00:00
Collecting python-dotenv
  Downloading python_dotenv-0.21.0-py3-none-any.whl (18 kB)
Collecting python-pushover
  Downloading python-pushover-0.4.tar.gz (19 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [1 lines of output]
      error in python-pushover setup command: use_2to3 is invalid.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
marcin@pc:~/medihunter$ 

System details:

marcin@pc:~/medihunter$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.1 LTS
Release:        22.04
Codename:       jammy
marcin@pc:~/medihunter$ 

Unsuccessful logging in

Używam:
medihunter my-plan --user moj_login --password moje_haslo
Dostaje:
Unsuccessful logging in

Jakiś pomysł czemu tak?

Jak aktywować powiadomienia?

Jestem początkujący i mam problem z uruchomieniem powiadomień w medihunter.py

Co dokładnie powinienem zrobić z komendami

bash

export NOTIFIERS_PUSHOVER_TOKEN=avykwnqc8ohyk73mo1bsuggsm3r4qf
export NOTIFIERS_PUSHOVER_USER=s4g1zoewbzseogp4knrapx23k9yi95

Próbowałem je wpisać do kodu w medihunter.py lub wykonać w terminalu osobno ale w obu sytuacjach kod przestaje działać i wyrzuca błąd.
Mógłbyś krok po kroku opisać jak to połączyć z resztą kodu?

Z góry dzięki :)

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.