Screenshotter url test
This commit is contained in:
parent
ceceef8fb2
commit
6723f3d4d2
3 changed files with 17 additions and 11 deletions
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
name: E-Paper Screenshotter
|
||||
version: 1.0.1.19
|
||||
version: 1.0.1.20
|
||||
#image: ghcr.io/maxwinterstein/homeassistant-addon-toogoodtogo-ha-mqtt-bridge-{arch}
|
||||
slug: screenshotter
|
||||
description: Screenshot images for E-Paper pricetags
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
from selenium import webdriver
|
||||
from selenium.webdriver.chrome.options import Options
|
||||
from seleniumwire import webdriver
|
||||
from seleniumwire.webdriver.chrome.options import Options
|
||||
from seleniumwire.webdriver.common.desired_capabilities import DesiredCapabilities
|
||||
from PIL import Image
|
||||
import time, os
|
||||
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
||||
import yaml
|
||||
import datetime
|
||||
import croniter
|
||||
|
@ -60,15 +60,21 @@ while True:
|
|||
logging.info(f"Running {task['name']}")
|
||||
driver = webdriver.Chrome(options=chrome_options, desired_capabilities=d)
|
||||
driver.implicitly_wait(10)
|
||||
driver.get(task["url"])
|
||||
time.sleep(int(wait))
|
||||
|
||||
if task.get("ha_auth"):
|
||||
logging.info("Doing HA Auth")
|
||||
driver.execute_script(f"window.localStorage.setItem('hassTokens', JSON.stringify({{hassUrl: '{ha_url}', access_token: '{ha_token}', token_type: 'Bearer'}}));")
|
||||
driver.get(task["url"])
|
||||
time.sleep(int(wait))
|
||||
def interceptor(request):
|
||||
if request.headers['Authorization']:
|
||||
del request.headers['Authorization'] # Remember to delete the header first
|
||||
request.headers['Authorization'] = f"Bearer {ha_token}" # Spoof the referer
|
||||
driver.request_interceptor = interceptor
|
||||
#logging.info("Doing HA Auth")
|
||||
#driver.execute_script(f"window.localStorage.setItem('hassTokens', JSON.stringify({{hassUrl: '{ha_url}', access_token: '{ha_token}', token_type: 'Bearer'}}));")
|
||||
#driver.get(task["url"])
|
||||
#time.sleep(int(wait))
|
||||
|
||||
driver.get(task["url"])
|
||||
time.sleep(int(wait))
|
||||
|
||||
logging.info("Making screenshot")
|
||||
|
||||
# save screenshot
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
selenium
|
||||
selenium-wire
|
||||
Pillow
|
||||
pyyaml
|
||||
croniter
|
||||
|
|
Loading…
Reference in a new issue