I have pulled a few things from other answers today (this for instance: open a browser page and take screenshot every n hour in python 3)
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
browser = webdriver.Firefox()
browser.implicitly_wait(30)
browser.get('https://weather.com/en-AU/weather/today/l/ASXX0023:1:AS?Goto=Redirected')
time.sleep(10)
browser.save_screenshot('screen_shot.png')
browser.close()
this solution is working perfectly except I'm not sure how to execute in crontab.
i tried this after typing crontab -e then:
*/30 * * * * export DISPLAY=:0 /usr/local/bin/python3.9 /Users/path/script.py >> /path/screenshot.png
and it opens the firefox window, but the screenshot is Zero Bytes.. so it's close to what I want, but not quite there.
I tried a few other ways too - with script.sh - though I'm not to sure how to get that working either.
Also - it'd be good to add the time and date to the screenshot, so any help there is a blessing.
could you offer any guidance? Thanks!
>> /path/screenshot.pnglooks wrong but harmless. I'm guessing you are doing something even more bewildering in your real code. Probably redirect the script's output (and standard error) to a log file instead.DISPLAY=:0looks wrong for a Mac, or are you really running X11? Again, it should be harmless per se, but betrays a poor understanding of the pieces you have cobbled together./Users/name/code/screenshot.pngis the crontab path I'm using. there was no mention of Darwin on any previous sites - I'll look into it.