import time
from selenium import webdriver
# Set the path to your Chrome driver executable
driver_path = 'path/to/chromedriver'
# Set the URL of the website you want to take screenshots of
website_url = 'https://example.com'
# Set the time interval between each screenshot (in seconds)
screenshot_interval = 60
# Create a new instance of the Chrome driver
driver = webdriver.Chrome(driver_path)
# Function to take a screenshot
def take_screenshot():
timestamp = time.strftime('%Y%m%d%H%M%S')
screenshot_path = f'screenshot_{timestamp}.png'
driver.save_screenshot(screenshot_path)
print(f'Screenshot saved: {screenshot_path}')
# Main program loop
try:
while True:
# Open the website URL
driver.get(website_url)
# Take a screenshot
take_screenshot()
# Wait for the specified interval before taking the next screenshot
time.sleep(screenshot_interval)
except KeyboardInterrupt:
# Close the browser and exit the program if interrupted
driver.quit()