Python scripts for SEO/SEM and digital marketing

A set of Python scripts to automate various SEO/SEM and digital marketing tasks. Mostly using advertools, and made massively simpler by uv.

How to run Python scripts

These scripts are meant to be self-contained and complete in and of themselves, and should be straight forward to follow. Yet, you have a few choices of running them.

The easiest way is to run the scripts with uv, so make you sure you are familiar with that. Here are the options recommended in order:

  1. Running with uv remotely

The easiest way to use run those scripts on your local machine while the script is on this server. The uv package allows running remote scripts hosted on another host. From the command line:

uv run https://example.com/script.py ARG1 ARG2 ...

This way, you don’t even need to download the files (although uv will do so temporarily), and more importantly you will make sure you have the latest version in case there are recent updates and/or bug fixes. You can download it if you want of course. Please check the code before running it, and make sure you are ok with its contents.

  1. Running with uv locally

You download the script to your local machine and run it with uv:

uv run my_script.py ARG1 ARG2 ...
  1. Running with Python

This is the traditional approach where you run with the command python from the command line. You will need to download the script, create a Python virtual environment, activate it, and then you can run it:

python my_script.py ARG1 ARG2 ...

Python scripts

This is a collection of scripts that you can run as described above, and each has its own short how-to guide to explain step by step, in case you want to introduce any changes.

The links go directly to the script .py files, so you can run them remotely, and you can check out the /how-to/ section for more details on what is going on and how you might modify them.

How to check if robots.txt rules are blocking URLs in your XML sitemap

Supply a robots.txt URL and the script will check all URLs in the sitemap(s) it finds and report if any are blocked.

How to Download, Parse, and Visualize XML Sitemaps

This will discover and download all sitemaps in the given robots.txt file, and produce three files: a CSV file of the sitemap, an interactive HTML chart showing publishing trends, and an interactive HTML chart showing the site’s URL structure.

How to get status codes of URLs in XML sitemaps

This will extract all URLs from the sitemap(s) found in the given robots.txt file, and run a status code check on them. It prints the non-200 URLs and their status code, and saves the crawl in a file for futher checking/analysis.