mdeweerd / MetersToHA

Get Meter Data into Home Automation systems
GNU General Public License v3.0
26 stars 8 forks source link

fix: fix grdf login page connection #27

Open bsegault opened 2 weeks ago

bsegault commented 2 weeks ago

Tentative the correction pour la connexion au site de GRDF, pour fixer #26

J'ai remarqué que la page de login est désormais divisée en deux : d'abord l'adresse mail et un boutont "Suivant", puis le mot de passe et un bouton "Se Connecter".

Je n'ai également pas constaté de captcha, et ai rajouté la possibilité désactiver la résolution de captcha via la configuration. Il y a peut-être mieux à faire, je suis preneur de suggestions.

J'ai toujours une erreur après-coup, dont voici le log:

2024-08-30 14:09:15,393 : WW :  Captcha resolution is disabled by config. The following steps may not work.
2024-08-30 14:10:44,483 : WW : Automatic resolution succeeded. Grab & Save '/workdir/apps/meters_to_ha/screen_before_connection.png'. Wait for Button xpath://input[@value='Se Connecter']. Get Data URL https://monespace.grdf.fr/api/e-conso/pce/consommation/informatives?dateDebut=2024-08-16&dateFin=2024-08-30&pceList[]=***Get data url second time in 5 secondsGet Data Content. No downloaded File. <pre> Element not found. This may be due to an issue with the captcha resolution. Check the log for other errors and check your captcha solver configuration Traceback (most recent call last):
-   File "/workdir/apps/meters_to_ha/meters_to_ha.py", line 3462, in doWork
-     gazpar_file = crawler.get_gazpar_file()
-   File "/workdir/apps/meters_to_ha/meters_to_ha.py", line 1977, in get_gazpar_file
-     raise ValueError("No content") - ValueError: No content
2024-08-30 14:10:44,484 : WW :  Encountered error -> Retrying once
2024-08-30 14:10:48,771 : OK : Connexion au site GRDF
2024-08-30 14:10:49,352 : OK : Waiting for Email
2024-08-30 14:10:49,606 : OK : Type Email
2024-08-30 14:10:49,629 : OK : Wait for Button xpath://input[@value='Suivant'].
2024-08-30 14:10:49,630 : ~~ : Wait before clicking (1.7s).
2024-08-30 14:10:51,501 : OK : Click on connexion
2024-08-30 14:10:52,094 : OK : Waiting for Password
2024-08-30 14:10:52,209 : OK : Type Password
2024-08-30 14:10:52,210 : -- : Proceed with captcha resolution. method=nocaptcha, key=True
2024-08-30 14:10:52,210 : WW :  Captcha resolution is disabled by config. The following steps may not work.
2024-08-30 14:12:21,550 : EE : Automatic resolution succeeded. Grab & Save '/workdir/apps/meters_to_ha/screen_before_connection.png'. Wait for Button xpath://input[@value='Se Connecter']. Get Data URL https://monespace.grdf.fr/api/e-conso/pce/consommation/informatives?dateDebut=2024-08-16&dateFin=2024-08-30&pceList[]=***Get data url second time in 5 secondsGet Data Content. No downloaded File. <pre> Element not found. This may be due to an issue with the captcha resolution. Check the log for other errors and check your captcha solver configuration No content
2024-08-30 14:12:21,613 : OK : Close Browser
2024-08-30 14:12:21,619 : OK : Close Display
2024-08-30 14:12:21,619 : EE :  Ended with error : // re-run with '--display' option if you can

Manuellement, j'arrive à récupérer le JSON référencé par le Data URL, et j'y vois bien un <pre> dans le DOM Inspector, donc s'il y a autre chose à faire, je ne vois pas quoi...

bsegault commented 2 weeks ago

This is actually a duplicate of #23 that seems to do more and better.