Python has risen in popularity in recent years, becoming one of the more popular programming languages, especially when it comes to automation.

What Is Python?

Python is a high level programming language that was first released in 1991. One of the main benefits of choosing Python, is the ease with which you can edit, test and debug your code. Additionally, Python was created to use incredibly simple syntax, making it easy to learn and build, whilst also being fairly simple to maintain.

I’m an SEO, so why should I care?

As an SEO, we all know it’s important to understand the basics of HTML, CSS and JS. Doing so can make your life so much easier when it comes to technical audits.

The reason you should care about Python, however, is due to the opportunities it gives you for automating some of the more low level tasks that would normally take you hours to complete.

Python automation is something I’d heard of for quite a while and read a few articles on here and there. So in recent months, I decided to dedicate a bit more of my time to learning Python and finding out how it can have a positive impact on SEO.

In this post, I’ll be sharing some of my personal favourite Python scripts for SEO, along with a brief description of what you can achieve with them.

Python SEO Analyzer

The first script featured in this list in the Python SEO Analyzer. This script will allow you to analyze a website page by page, to identify SEO issues on each page such as; missing metadata, duplicate page titles, missing markup and more.

On top of this, it also analyzes the word count across your website and gives you a keyword analysis of the most common words/phrases used throughout your website.

This can give you a great indication as to whether you’re overusing or underusing your core keywords.

This script, for me, is so useful as it takes a tedious task and makes it super easy to do. You can output your results to an HTML file making it nice and easy to digest.

To find further information and installation/usage instructions, you can access the GitHub repository here – https://github.com/sethblack/python-seo-analyzer

Crawl404

This script does exactly what it says on the tin, crawls and checks a website for any 404 links.

All you need to do is update the code with the sitemap of the website you’d like to check and then run the code. Now, there are a lot of other tools that can do this for you but, personally, I love the ease of just running it in my Terminal and getting instant results.

Sometimes, it’s the simple things in life that are the best!

https://github.com/yushulx/crawl-404

Optimize Images

This is an incredibly useful tool to help you quickly optimise image file sizes.

Using purely Python, the script can compress and optimise the file size of either single images or all images in your current directory. If you’re looking to speed up your website by compressing images, this is possibly the quickest and easiest way to do it.

One thing to note on this, however, is that the images are optimised destructively, meaning it will replace the original file with a new one. Therefore, we would always recommend creating copies of your images/directories before running this script, to ensure you have a backup should you need it.

https://github.com/victordomingos/optimize-images

Screaming Frog Shingling

As most SEOs will know, Screaming Frog is one of the most important tools to have in your arsenal but this script can help you take it to the next level.

The Screaming Frog Shingling allows you to take the results of your crawl, with custom extraction (you can see further instructions on that in the link below), and will compare the body text on all pages.

Once the comparison is complete, it will create a new CSV for you, which then includes a similarity score and also tells you the URL that contains that similarity.

If you have a nagging worry in the back of your head when it comes to duplicate content on a website, this tool is definitely worth your time!

https://github.com/jroakes/screaming-frog-shingling

How To Install Python

Reading about all of those scripts is super exciting, but they’re going to be pretty useless if you don’t have Python installed. If you already have Python installed, feel free to skip over this next section, if not, read on.

Some devices now come with a version of Python pre-installed, so the first step is to check if you already have it installed.

If you’re on a Windows device;

  1. Open up PowerShell (you can do this by opening your start menu and typing PowerShell)
  2. Input the following command and hit your enter or return key – Python –version
  3. If you see output similar to Python X.X.X, then python is installed. If you don’t see anything along these lines, you’ll need to install it (instructions further down)

If you’re on a Mac;

  1. Open up your Terminal. The easiest way to do this is by opening your spotlight search (by pressing cmd + spacebar), type in Terminal and hit enter
  2. Enter the following command and hit enter – Python –version
  3. If you see output similar to Python X.X.X, then Python is installed. If you don’t see anything along these lines, you’ll need to install it (instructions further down)

If you don’t have Python installed, here’s what to do – iIf you already have it installed, feel free to skip these next instructions.

If you’re on a Windows device;

  1. Head to the downloads section on the official Python website
  2. Download the latest version available at the time of installation. Ensure you click the Add Python to PATH option to save yourself headaches in the future
  3. Once the installation is complete, close your PowerShell, re-open it and follow the above instructions to test installation was successful.

If you’re on a Mac;

  1. Head to the downloads section on the official Python website
  2. Download the latest version available at the time of installation. 
  3. Once the installation is complete, close Terminal, re-open it and follow the above instructions to test installation was successful.

So there are a few of my personal favourite Python SEO scripts at the moment but believe me when I say there are many, many more where they came from. If you’re interested in starting to use Python to help increase your productivity and make life a little easier then I would recommend testing out the scripts linked above to get used to Python. 

Once you’re more comfortable using Python, GitHub has hundreds of Python SEO repositories that you can take a look through or better yet, you could build your own!

If you’re interested in learning a little more about Python, I would highly recommend checking out the articles below;

Using Python to recover SEO site traffic (Part one)

A Python Approach to SEO: Automating the Boring Stuff

How to Use Python to Analyze SEO Data: A Reference Guide

Bringing The Fun Back To SEO With Python – Benjamin Goerler

Beginner’s Guide to Python

Matt Jones

About Matt Jones

Rise at Seven's SEO and CRO Manager.