20220102 - UPDATE: As of release v5.7.0, Multiscrape could be used as a RESTful sensor as well, enabling you with all the benefits like form-submit, entity pictures, icon templates, etc.
20210608 - IMPORTANT UPDATE: release 4.0.0 upgraded this component to an integration. You can now also create binary sensors, still based on a single HTTP request.
It does come with a backward-incompatible change in the configuration though. Please check the upgrade notes! I also updated the example config below.
Not sure what you consider âeasy login promptsâ, but it does support HTTP authentication like in the RESTful sensor or you can send bearer tokens in an authorization header.
See: https://www.home-assistant.io/integrations/rest/
Have no need for it, and by the time I get that need I believe I have already forgotten about this and will just set up two separate scrapers.
But nice work!
Would be nice if this could be merged in with the core.
With âeasy login promptsâ I meant login to site that requires username and password for login. So itâs x amount harder but still doable. I have working code but itâs only for this specific website and I havenât got to translate it to HA custom component. I was thinking that maybe this component could be extended (maybe a bit wishful thinking). Maybe I have to take your code and extend it
Update: I created a new release which now uses the lxml parser (which is better). For backward-compatibility, the old âhtml.parserâ-parser could still be configured.
There are things that this script cannot find automatically and some html reading skills are needed from you. You need to tell it what is URL of login page. This can be same or different page you are scraping. Preloginform is the name parameter of <form> tag in html. So in my example itâs <form name="loginForm">.
Username_field and password_field are inputâs from html. So in my example those are like <input type="text" name="username"> and <input type="password" name="password">.
Username and password are what you expect. They are the real credentials to be filled out to the form and submitted to the site.
Should this be moved to an another discussion as this is not about the current version of hass-multiscrape and itâs not even sure if this ever will be part of it. @danieldotnl what do you think?
Are you attempting to be able to login to HTML forms? I was just wanting to look into that. Iâd like to pull the overnight usage data from my CPAP machine. But it is behind an HTML form.
Yes, that is exactly what my code is doing. I have it now working in my dev system. But I have only tested it with one site now. Maybe I should just share it for others to test it also.
Just notices that @danieldotnl has been busy also and updated his code. So this doesnât include any of his new improvements (each item as separate sensor).
OK, so my login form does not have a name nor id property. But it does have a unique class and a unique action. I just submitted a Pull Request to your fork which checks all 4 form attributes.
Thanks for your input @BrianHanifin! Itâs now merged to my repo.
Next I should update my version to match original. We would get multiple sensors instead of multiple attributes. Then maybe do pull request to the original.