How to Automate Screenshots with Python (Scheduled and Timed)

Profile

Written By Hanzala Saleem

Updated At June 23, 2026 | 6 min read

If you need to take screenshots of a competitor’s website every day or keep up with the stock prices, you don’t have to set a timer on your phone. You just need to know how to take timed screenshots automatically.

To automate screenshots with Python, write a short script that calls a screenshot API, then wrap it in a scheduler so it runs on a timer. With about 20 lines of code and the schedule package, you can capture any website every morning, every hour, or every few minutes, and save each image automatically.

This guide gives you the full script, shows how to set custom intervals, and explains when a managed scheduler is the better choice. No phone timers, no manual clicking.

What Is Screenshot Automation?

Screenshot automation is the practice of capturing website screenshots through code or a scheduler instead of pressing a key each time. A script sends a target URL to a screenshot API, receives the rendered image, and saves it to disk. Adding a scheduler, such as Python's schedule library or a cron job, lets the same script run on a fixed timer: every minute, hour, or day, with no one watching. This turns one-off captures into a repeatable, hands-off monitoring pipeline.

Taking Timed Screenshots Automatically

To illustrate how you can take timed screenshots automatically, we’ll write a simple script you can use to do this. In our script, we’ll use the schedule package, combined with the script we used to take screenshots with Python

Step 1: Install the schedule Package

We will build on the basic script from our guide to taking screenshots with Python and add the schedule package to handle timing. Install it from your terminal:

pip install schedule

That is the only extra dependency. The screenshot itself is handled by a single API call, so there is no headless browser to install or maintain on your machine.

Step 2: Import the Packages

Once we’ve installed the package on our system, we can start writing our script. 

First, we need to import all the packages we’ll need; scheduletimessl, and the parse and request modules of the urllib package. 

We’ll also create an unverified SSLContext object, as we did in our previous post. 

import schedule
import time
import ssl
import urllib.parse
import urllib.request

# Use an unverified SSL context, as in the basic Python example
ssl._create_default_https_context = ssl._create_unverified_context

Step 3: Define Your Variables

Set your API key, the target URL, the output type, and the file format. Get your API key and the endpoint from your ScreenshotAPI dashboard.

token = "YOUR_API_KEY"                              # from app.screenshotapi.net
target_url = urllib.parse.quote_plus("https://example.com")
output = "image"
file_type = "png"

Step 4: Build the Request URL

Combine the base endpoint with your variables to form the full request:

query = "https://shot.screenshotapi.net/v3/screenshot"
query += "?token=%s&url=%s&output=%s&file_type=%s" % (token, target_url, output, file_type)

Add &fresh=true to the query if you want to skip the cache and force a brand new capture on every run.

Step 5: Wrap the API Call in a Function

Functions allow you to create blocks of reusable code that perform a specific task. So, unlike our previous example, we’ll write a function that will call the API. 

To do this, we’ll use the def keyword, name our function, and place the call to the API within our function code block.

def get_screenshot():
    filename = "screenshot.png"
    urllib.request.urlretrieve(query, filename)
    print("Saved", filename)

With the code up to now, the script will take a screenshot of a specific website, except the call to the API is now contained in the get_screenshot function. 

Remember, though, that we want to take timed screenshots. 

Step 6: Put the Capture on a Timer

The schedule package turns the function into a recurring job. This example runs get_screenshot every morning at 8:00 and keeps running until you stop it:

schedule.every().day.at("08:00").do(get_screenshot)

while True:
    schedule.run_pending()
    time.sleep(1)

To avoid overwriting the same file, give each capture a unique, timestamped name:

from datetime import datetime

def get_screenshot():
    filename = datetime.now().strftime("screenshot_%Y-%m-%d_%H-%M.png")
    urllib.request.urlretrieve(query, filename)
    print("Saved", filename)

Now every run saves a separate, dated image, which is ideal for building a visual history of a page over time.

Take Screenshots at Custom Intervals

The schedule package is not limited to a daily time. Swap the timing line to capture a page on any cadence you need:

schedule.every(10).minutes.do(get_screenshot)   # every 10 minutes
schedule.every().hour.do(get_screenshot)         # every hour
schedule.every().monday.do(get_screenshot)       # once a week

For very short intervals, such as every few seconds, keep the page light and watch your API usage, since each run is a separate request. Short intervals suit live dashboards and incident monitoring, while hourly or daily runs suit competitor tracking and compliance records.

Running It in Production: Cron and Managed Scheduling

The while True loop works while your machine stays on, but it stops the moment you close your laptop or reboot. For anything that has to run reliably, you have two stronger options.

On a server, drop the loop and let cron trigger a one-shot version of the script. Save the capture logic as capture.py and add a crontab entry:

0 8 * * * /usr/bin/python3 /path/to/capture.py

If you would rather not run a server at all, ScreenshotAPI offers managed recurring scheduling that runs in the cloud, stores every image, and emails you when each capture completes, so nothing depends on your own machine staying awake.

DIY Script vs No-Code vs Managed Scheduling

ApproachBest forRuns without your machine onBuilt-in storage and retries
Python script + scheduleDevelopers who want full control and local filesNoNo, you add it
Python script + cron on a serverDevelopers with an always-on serverYesNo, you add it
No-code (Zapier or n8n)Non-developers wiring screenshots into a workflowYesPartial, via the connected app
Managed recurring schedulingTeams that want set-and-forget capture and an archiveYesYes

Pick the script if you want code you control. Pick a managed scheduler if reliability and a stored archive matter more than custom code.

Start Taking Timed Screenshots Now

Hopefully, this post added another weapon to your screenshot-taking arsenal, and you’ll now be able to automatically take timed screenshots when you need them with ScreenshotAPI. To learn more about ScreenshotAPI’s range of features and how it makes taking advanced screenshots a breeze, register for your free API key today. 

Frequently Asked Questions

How do I take a screenshot every X minutes in Python?

Use the schedule package and set the interval with schedule.every(X).minutes.do(get_screenshot), then run a loop that calls schedule.run_pending() each second. Replace X with any number, or use .hour or .day for longer gaps. Each run is a separate API request, so shorter intervals use more of your quota.

Do I need to keep my computer on for scheduled screenshots?

Yes, if you use the while True loop, because the script only runs while the process is alive. To capture without your machine staying on, run the script from cron on an always-on server, or use a managed scheduler that runs the job in the cloud and stores each image for you.

What is the difference between the schedule library and cron?

The schedule library times jobs inside a running Python process and is quick to set up for local use. Cron is an operating-system scheduler that triggers a script on its own, so it survives reboots and does not need a loop. Use a schedule for simple local runs and cron for server reliability.

Can I save each screenshot with a unique filename?

Yes. Build the filename from the current date and time inside the function, for example using datetime.now().strftime("screenshot_%Y-%m-%d_%H-%M.png"). Every run then writes a separate, timestamped file instead of overwriting the previous one, which lets you build a visual history of a page.

How is this different from the Schedule Website Screenshot feature?

The script in this guide is the do-it-yourself, code-first route that you host and control. The Schedule Website Screenshot feature is the managed version: you set the cadence in a dashboard, captures run in the cloud, and every image is stored automatically.