sensors/export/main.py

40 lines
1023 B
Python
Raw Normal View History

2022-12-19 19:30:06 +00:00
import time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
2023-04-18 20:25:22 +00:00
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
2022-12-19 19:30:06 +00:00
2023-04-18 20:25:22 +00:00
ser = Service('/usr/lib/chromium-browser/chromedriver')
2022-12-19 19:30:06 +00:00
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
2023-04-18 20:25:22 +00:00
driver = webdriver.Chrome(service=ser, options=chrome_options)
2022-12-19 19:30:06 +00:00
driver.get('https://sensors.dns.t0.vc')
time.sleep(3)
2023-04-18 20:25:22 +00:00
graphs = [
'Solar_Power',
'Living_Room_Air',
'Outside_Temperature',
'Bedroom_Temperature',
'Nook_Temperature',
'Misc_Temperature',
'Nook_Thermostat',
'Gas_Usage',
'Water_Usage',
'Living_Room_Lux',
]
2022-12-19 19:30:06 +00:00
2023-04-18 20:25:22 +00:00
for graph in graphs:
print('Capturing', graph, 'graph...')
element = driver.find_element(By.ID, graph)
with open('data/{}.png'.format(graph), 'wb') as f:
f.write(element.screenshot_as_png)
2022-12-19 19:30:06 +00:00
driver.close()
2023-04-18 20:25:22 +00:00
print('done.')