I am currently trying to scrape a local web page, generated by my EV charger. I access it through it’s IP address, which requires me to sign in.
After signing in, I want to retrieve the data from the JS chart below. This data is shown in chunks (not even 1 complete day visible), but it goes way back (1 year +).
I want to use this data, to compare my EV charging sessions with my available power in house.
However, I struggle so far to extract the data shown in the chart, and then make it iteratively go back in time, clicking the arrow below.
driver_path = r"C:\chromedriver-win64chromedriver.exe"
ACCOUNT = "[email protected]"
PASSWORD = "pw"
driver = webdriver.Chrome(driver_path)
driver.maximize_window()
wait = WebDriverWait(driver, 10)
driver.get("http://192.168.1.245/#!/login")
#login to my charger
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@type='text']"))).send_keys("[email protected]")
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@type='password']"))).send_keys("pw")
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[@type='submit']"))).click()
#Using this code, I can extract the y-axis and x-axis, with the visible parameters.
el = driver.find_element(By.XPATH, "//div[@id='powerManagementDashboard']//*[local-name()='svg']").text
print(el)
08:00
09:00
10:00
11:00
12:00
13:00
-10
0
10
20
30
40
50
kW
#go back in time clicking the left arrow.
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//i[@ng-click='ChartAddHour(-6)']"))).click()
But I can’t work out how to scrape the most important section in the HTML, with an abundance of <g> tags
, of which only one I need.
In the image below the data is shown. I want to retrieve the datapoints that contain the time and the measured kW at that point.
But how do I get to that specific <g>
? Or scrape all of those <g> tags
, and clean the data later.
Wondering if anyone can help me out. Thanks in advance.