How to Automate Website Screenshots [TECH GUIDE]

Post by
Andrew Pierno
How to Automate Website Screenshots [TECH GUIDE]

From time to time, whether you need screenshots for web scraping, monitoring user or competitor behavior, or any other use case, you might need to take screenshots automatically. And, often, you’ll need to take them in bulk.

So in this post, we’ll show you how to automate screenshots quickly and easily through code and no-code methods.

Preview: Methods to Take Programmatic Screenshots

  • Using extensions, tools, and APIs
  • Automating website screenshots with code: Python (using a list for programmatic screenshots, text files, or taking time-based screenshots), JavaScript, other programming languages
  • Using ScreenshotAPI's Query Builder
  • No-code methods to automate website screenshots
  • FAQ

First, Why Do You Want to Automate Screenshots?

Before you choose an automated screenshot tool, know your why. Your reason for needing automated screenshots will dictate the functionality you need.

  • Do you want to track and monitor website behavior as a developer? You’ll need a solution that’s integrated with your existing stack.
  • Monitor your competitors' pricing and website strategies to position your business properly and get a competitive advantage. 
  • Monitor website compliance to ensure consistent branding, messaging, and tone of voice. More importantly, you’ll ensure your products comply with relevant regulations. 
  • Track your website’s SERP performance. See how your website’s ranking improves over time and spot any issues before they become bigger problems. 
  • Archive your social media posts and activity. You’ll typically do this for compliance reasons. 
  • Automating workflows when working with different dashboards? Focus on integrations.
  • Keeping track of designs? Look for HD screenshots.
  • Streamline debugging or any other repetitive IT task

And more! These are just a few examples. If you often need to save website screenshots, it’s much better to automate the task than waste hours doing it manually.

3 Simple Ways to Automate Website Screenshots

Now that we’ve seen why you’d want to automate screenshots, let’s look at how you can do it. Here, we’ll look at a few options you might consider, depending on your requirements. 

Method #1. Extension, Tools, and APIs

One of the simplest ways to automate website screenshots is by using one of the many browser extensions, tools, and APIs available. 

Luckily, there are tons of screenshot tools available, so you won’t have any difficulty finding one that meets your needs. 

To get you off to a good start, here are some of the best options you can consider:

  • ScreenshotAPI. Our tool, ScreenshotAPI, gives you an all-in-one tool that you can use to automate screenshots for any requirement. As such, apart from providing a simple way to take website screenshots quickly and easily, it also offers advanced features like ad removal, timed screenshots, text extraction, and more.
  • URLBox. URLBox provides you with an API that makes it easy to take website screenshots automatically. It gives you complete control over the size, quality, and format of the images, and you can use a variety of programming languages with it. 
  • URL2PNG. URL2PNG is a screenshots-as-a-service platform that simplifies the process of taking automated screenshots. It also provides several advanced features that give you full control over the results. 
  • Snagit. While Snagit makes it easy to take screenshots directly from your browser, it also provides several other noteworthy features like screen recording, text extraction, annotations, and more. 
  • Fireshot. As a browser extension for almost all popular browsers, Fireshot makes it easy for anyone to take website screenshots quickly and easily. Unfortunately, it’s hard to automate it. 

Method #2. Automating Website Screenshots with Code

While not as simple as using a tool or extension, using code to automate website screenshots sometimes gives you more customization options. 

More importantly, when you use code, you can implement screenshot features and functionality into your apps. You can use libraries or modules provided by programming languages themselves, or you can use pre-developed APIs.

Using Python

For instance, you can use the pyautogui module to take a screenshot in Python. Here is the code you’ll use to do this:

Python code to take screenshots

This code takes a screenshot and saves it in the location provided. Quite simple, right? The problem is that, with this method, you’ll need to manually navigate to every screenshot you’d like to take. 

This is a much better alternative:

Automating Website Screenshots with Python and ScreenshotAPI

There are a few simple ways to use ScreenshotAPI as your programmatic screenshot-taking tool. You can always manually request screenshots, but if you’re an advanced user, you’ll love the simple integration.

Once again, we’ll use Python.

Setting Up

 To start, you’ll need to do some preparation, similar to our previous post. So, import the parse and request modules of Python’s urllib package with the following code:

import urllib.parse
import urllib.request

Then import Python’s ssl module with the code:

import ssl

The ssl module gives you access to Transport Layer Security encryption and peer authentication facilities for network sockets. When you’ve imported the ssl module, you can create an unverified SSLContext object, which allows you to access websites without valid SSL certificates:

ssl._create_default_https_context = ssl._create_unverified_context

Next, you’ll set the variables you’ll use to construct the query parameters. First, define the token variable, which is a string containing your ScreenshotAPI API key:

token = “Your API Key”

Then set the width and height of your target render. These are both integers:

width = 1920
height = 1080

Remember, you don’t have to use the same numbers we’ve used here; you can choose those that best meet your needs. You’ll then also define your output variable, a string that specifies the output format, either as an image or in JSON format. In this case, we’ll output images:

output = “image”

We haven’t set our url variable because we’ll do so when we deal with the different methods for automating screenshots.

Python code to automate website screenshots

Method 1: Using a List

The first method, a Python list, is probably the simplest of all the techniques we’ll use. To start, you’ll put all the websites you want to take screenshots of in a Python list. We’ll use a few search engines and news sites in our example.

url_list = [“”, “”,””, “”, “”]

Next, we’ll iterate through the list using a For loop, and with each iteration, we’ll set the url variable, construct the query parameters, and call the API:

for item in url_list:
url = item
query = ""
query += "?token=%s&url=%s&width=%d&height=%d&output=%s" % (token, url, width, height, output)
urllib.request.urlretrieve(query, "./screenshot.png")

This script will iterate through your entire list and take and save a screenshot for every website on your list.

Method 2: Using a Text File

While the list method mentioned above can be effective, it could become quite cumbersome if you have a lot of websites you want to take screenshots of. 

Don’t worry, you don’t run it separately every single time - we wouldn’t want you falling asleep on us!

Instead, you just use a text file.

Let’s say you have a text file, saved as urllist.txt, with the following content:

You'll use the same process described above, but you’ll first need to open the file for Python to read it. To do this, you’ll use the with statement with open and set the mode to r for reading:

with open(“urllist.txt”, ”r”) as url_file:

With the file open, you’ll again use a for loop to iterate through the items in your text file:

for line in url_file:

With each iteration, you’ll set the url variable, strip the end-line break from the line, construct the query parameters, and call the API:

url = line.strip()
query = ""
query += "?token=%s&url=%s&width=%d&height=%d&output=%s" % (token, url, width, height, output)
urllib.request.urlretrieve(query, "./screenshot.png")

This script iterates through all the websites on your list, no matter how many, and takes a screenshot of each.

Method 3: Time Based

The methods described above work great if you want to take bulk screenshots of many sites, but what do you do if you want to take automatic screenshots of only one site? 

This could, for example, be for employee or user monitoring.

One of the simplest ways to do this is using the time module. You’ll need to import the module during the setup stage mentioned earlier. You’ll also set your url variable, and you’ll construct your query during the setup process:

import time
url = “”
query = ""
query += "?token=%s&url=%s&width=%d&height=%d&output=%s" % (token, url, width, height, output)

Next, you’ll use a while loop to let the code execute continuously, but with the sleep function to ensure that it only repeats in seconds after a given time period. For example, if you want a screenshot every ten minutes, your code will be:

urllib.request.urlretrieve(query, "./screenshot.png")

You can set this time period based on how often you want screenshots to be taken, and the script will then execute and save screenshots at these defined intervals.

Using JavaScript to Automate Website Screenshots

Likewise, when using JavaScript to take screenshots, you’ll use this code:

Javascript code to automate website screenshots

Taking Screenshots in Other Programming Languages

You can also use code to take screenshots by using the ScreenshotAPI API in PHP, Java, and Ruby. (Click through to read our complete guides with code samples.)

Once you decide to use code to take screenshots, it’s time to automate the process. 

For instance, you can use a list to take screenshots of several websites in succession. Here’s the Python code to do that:

Python code to automate website screenshots

This code will iterate through the list and call the API for every URL. Besides a list, you can also use a text or CSV file to automate your screenshots. 

You can approach automation this way, regardless of your preferred programming language. However, remember that the language conventions and syntax will differ.

Method #3. Using ScreenshotAPI’s No-Code Query Builder to Automate Website Screenshots [Example]

The simplest way to automate your screenshots is by using ScreenshotAPI’s No-Code Query Builder. 

Enter the URL you’d like a screenshot of, and choose your required screenshot options.

Let’s assume you’d like to take a full-page screenshot and block any ads. 

The first step is to log into Screenshot API and head over to the Query Builder. 

Taking automated website screenshots with ScreenshotAPI

Let’s say you’d like to take a screenshot of Amazon’s homepage in full high-definition resolution. So, you’ll enter those details into the query builder. 

And remember, you want a full-page screenshot, so you’ll also select that option.

Taking automated website screenshots with ScreenshotAPI

To block the ads, you’ll need to go to the advanced options by clicking Show Advanced Options. Here, you can choose the file and output type, set delays, scroll to specific elements, and more. To block the ads, you’ll check this box:

Taking automated website screenshots with ScreenshotAPI

Once you’ve chosen all your options, you can take the screenshot by clicking Take Screenshot at the bottom of the page. 

However, to automate your screenshots, you can copy the API query and use it in combination with code to get the screenshots you require. 

In this example, based on your requirements, this would be your query:

Sample API query to automate website screenshots with ScreenshotAPI

No-Code Automation

Are you using no-code methods? You can easily take automated and periodic website screenshots with ScreenshotAPI,, and Google Drive.

Apart from blocking ads, there are a ton of other options available. So, the best way to learn about everything the query builder can do is to get started for free and play around with it. 

Automate Your Screenshots Now With ScreenshotAPI

And that’s it! ScreenshotAPI gives you plenty of ways to programmatically take screenshots (and choose the exact cadence that fits your workflow best). There’s no reason to jump through hoops anymore.

You’re one API key away from getting screenshots off your to-do list! 

Head over to ScreenshotAPI to register a free account, or start using your account to get more mileage out of your automation and free up enough time to grab a cup of coffee (or two). 😊

But wait! Before we go – these are a few questions our customers often have when automating website screenshots:


How do I automate the screenshot process?

You can easily automate the screenshot process using any of the above methods. To find the right one, you’ll need to consider your unique needs and requirements to figure out which way will be the best fit.

How do I take a long scrolling screenshot?

Considering that most websites implement this feature, you must be able to take scrolling screenshots. Fortunately, with ScreenshotAPI, taking scrolling screenshots is quite simple. You just have to log into the Query Builder and select this option, as we’ve described earlier. 

How do I take screenshots using the command prompt?

Windows does not provide a native tool for taking screenshots from the command line. So, you’ll typically need a third-party application to take screenshots from the command line by executing a simple command. 

How do I automate screenshots in Selenium?

Selenium is a tool that helps you automate several browser actions so that you can automate screenshots in Selenium easily. Our guide on the link explains how to use Selenium with Ruby.

How do I automatically take and share screenshots of a webpage?

Use ScreenshotAPI to take your screenshots, then integrate it with and create a workflow that automatically shares screenshots to your preferred channel. Need help? We wrote a complete guide with the steps explained!