MichaelBach
(Michael Bach)
September 30, 2024, 11:10am
1
I need some assistance with scraping a website. I think I did it correctly, but my login seems to fail. Can any of you give me a hint or pointer to where I go wrong.
- name: Hp1 Scraper
resource: https://www.myheatpump.com/a/login?__url=https%3A%2F%2Fwww.myheatpump.com%2Fa%2Famt%2Frealdata%2Fimg%3Fmn%3D3706%26devid%3D1
log_response: true
scan_interval: 60
form_submit:
submit_once: true
resource: https://www.myheatpump.com/a/login
select: "#login-form"
input:
username: Ta*****40
password: V***********4
The responses I get, is all a login site. So I assume it does not login as It should. I think I got the correct forms and everything.
I have exactly the same problem with the same login address. I have tried different forms and inputs without much difference. I have also tried some python scapers with the same result. I was hoping to get it work because no modbus to use.
Still relevant or not, I got it working at least somehow using AppDaemon python script running selenium chromedriver.
Something like this:
import datetime
import time
import appdaemon.plugins.hass.hassapi as hass
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
class MyHeatpump(hass.Hass):
def initialize(self):
minutely = datetime.time(0, 0, 0)
self.run_minutely(self.pumpStatus, minutely)
def pumpStatus(self, ps_args):
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-gpu')
options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome(options=options)
driver.get('https://www.myheatpump.com/a/login')
time.sleep(2)
driver.find_element(By.ID, "username").send_keys("mysername")
driver.find_element(By.ID, "password").send_keys("mypassword")
driver.find_element(By.ID, "btnSubmit").click()
time.sleep(3)
# Sensors from "Real time data" page
driver.get('https://www.myheatpump.com/a/amt/realdata/form?mn=9999&devid=1')
time.sleep(2)
self.set_state("sensor.outdoorTemperature", state = driver.find_element(By.ID, "par24").get_attribute("value"), attributes = {"friendly_name": "Ourdoor temperature", "device_class":"temperature"})
...
# Sensors from "Running view" page
driver.get('https://www.myheatpump.com/a/amt/realdata/img?mn=9999&devid=1')
time.sleep(2)
self.set_state("sensor.Tuo", state = driver.find_element(By.NAME, "par4").text, attributes = {"friendly_name": "Water OUT temperature", "device_class":"temperature"})
...