I want to open a web page then take a screenshot every 2 hours via python. here is my code to open a page at every 2 hour interval
import time
import webbrowser
total_breaks = 12
break_count = 0
while(break_count < total_breaks):
time.sleep(7200)
webbrowser.open("https://mail.google.com/mail/u/2")
break_count = break_count + 1
i followed Take a screenshot of open website in python script but didn't get any success I am using python 3.5 . I got a module wxpython but it supportts only 2.x . So is there way to take a screen shot every 2 hours using python 3
Here's what you have to with Selenium to get started.
pip install selenium
in the command prompt.from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
browser = webdriver.Firefox()
browser.implicitly_wait(30)
browser.get('https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1<mpl=default<mplcache=2&emr=1&osid=1#identifier')
email = browser.find_element_by_xpath('//*[@id="Email"]')
email.clear()
email.send_keys("email@gmail.com") # change email
email.send_keys(Keys.RETURN)
password = browser.find_element_by_xpath('//*[@id="Passwd"]')
password.clear()
password.send_keys("password") # Change Password
password.send_keys(Keys.RETURN)
time.sleep(10)
browser.save_screenshot('screen_shot.png')
browser.close()
schtask
on the saved python file from the command prompt.
schtask
is the CRON
equivalent on windows.schtasks /Create /SC MINUTE /MO 120 /TN screenshot /TR "PATH_TO_PYTHON_FILE\FILE.py"