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
|
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}
|
#image: ghcr.io/maxwinterstein/homeassistant-addon-toogoodtogo-ha-mqtt-bridge-{arch}
|
||||||
slug: screenshotter
|
slug: screenshotter
|
||||||
description: Screenshot images for E-Paper pricetags
|
description: Screenshot images for E-Paper pricetags
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
from selenium import webdriver
|
from seleniumwire import webdriver
|
||||||
from selenium.webdriver.chrome.options import Options
|
from seleniumwire.webdriver.chrome.options import Options
|
||||||
|
from seleniumwire.webdriver.common.desired_capabilities import DesiredCapabilities
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
import time, os
|
import time, os
|
||||||
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
|
||||||
import yaml
|
import yaml
|
||||||
import datetime
|
import datetime
|
||||||
import croniter
|
import croniter
|
||||||
|
@ -60,15 +60,21 @@ while True:
|
||||||
logging.info(f"Running {task['name']}")
|
logging.info(f"Running {task['name']}")
|
||||||
driver = webdriver.Chrome(options=chrome_options, desired_capabilities=d)
|
driver = webdriver.Chrome(options=chrome_options, desired_capabilities=d)
|
||||||
driver.implicitly_wait(10)
|
driver.implicitly_wait(10)
|
||||||
driver.get(task["url"])
|
|
||||||
time.sleep(int(wait))
|
|
||||||
|
|
||||||
if task.get("ha_auth"):
|
if task.get("ha_auth"):
|
||||||
logging.info("Doing HA Auth")
|
def interceptor(request):
|
||||||
driver.execute_script(f"window.localStorage.setItem('hassTokens', JSON.stringify({{hassUrl: '{ha_url}', access_token: '{ha_token}', token_type: 'Bearer'}}));")
|
if request.headers['Authorization']:
|
||||||
driver.get(task["url"])
|
del request.headers['Authorization'] # Remember to delete the header first
|
||||||
time.sleep(int(wait))
|
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")
|
logging.info("Making screenshot")
|
||||||
|
|
||||||
# save screenshot
|
# save screenshot
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
selenium
|
selenium-wire
|
||||||
Pillow
|
Pillow
|
||||||
pyyaml
|
pyyaml
|
||||||
croniter
|
croniter
|
||||||
|
|
Loading…
Reference in a new issue