How to Use Python to Recover SEO Site Traffic?

In the past decade, Python has emerged as the most useful language because of the diversity of its applications.

It is an open-source programming language that is easy to learn, yet can surmount the most arduous tasks. Python is also high-level, i.e. reading the script gives you a good idea about what it is intended for.

A lesser-known fact is that Python can be used for SEO. Of course, you would need to hire Python developers to implement the code, but the end result would be rewarding.

A website is built using HTML, CSS, and JavaScript. These help in rendering the webpage and fetching data from the backend. How does Python fit into the scheme of things?

Python helps in technical SEO. One of the biggest plus points of Python is that it can be used for automation.

Using Python, you can compress several days of painstaking work in a few hours.
Python is also very suitable for data scraping. Hence, keyword research becomes easier. No more tedious reading of pages of blogs and going through website articles o find possible keywords that helped them rank.

Python can also analyze data generated by your site—who are the users, where do they log in from, what time are they most active, what they browse, what they buy, and so on.

Using Python for SEO

1. Seth Black’s Python SEO Analyzer

You must have come across SEO analyzers. They crawl through the web pages and provide feedback.

Most of the better ones come at a price or have a limitation on what you can get for free.

Seth Black’s SEO Analyzer is written in Python and can be found on GitHub.
It requires Python 3.6+, BeautifulSoup4, and urllib3 to run and can analyze the site structure, crawl the entire site and offer feedback about technical SEO.
The analyzer will find if your site has a meta tag where needed, a page title or H1, and meta descriptions.

It also provides you with a list of pages and words so that you can add content to those that are too brief. After all, Google likes authoritative sites which have at least a thousand words on every topic.

The tool also reports if alt-text tags are in place.

Following the recommendations of Seth Black’s Python SEO Analyzer alone would take your site a long way toward improving your technical SEO score.

2. Image Optimization

You need images to make the articles you publish interesting.

But images take up a lot of space. An average JPG image is about a megabyte in size at least.

Four of them make a page rather hefty. Add in the site structure and words and you end up with at least 6 MB.

Quite impossible to load in 2 seconds if a user is browsing and hunting for particular information on a weak connection.

Image compression is always possible, but how do you go back to 200 pages, extract 800 images and compress and place them back?

Easy. Use Python.

You can hire Python developers to write code for you. Otherwise, plenty is available off-the-shelf e.g. Python code to compress images at

An alternative can be found at Victor Domingos’ Python script from his GitHub page.

You can fiddle with the size of a few images or the whole site depending on how you set up the batch processing.

Reduce the size to 400 kilobytes (image quality would have to take a backseat, of course) and the pages would load swiftly.

To speed up further enable features such as lazy loading and you have superb page speed.

Page speed is a direct ranking factor for Google. Use PageSpeed Insights to know more.

3. Image Captioning

An SEO analyzer can tell you if alt-text is missing but it cannot write them for you.

Doing it by hand is almost impossible. Imagine opening hundreds of pages and creating alt-texts for every image located inside.

Facebook has a solution named Pythia that went open source in 2019.

The software literally inspects images pixel by pixel and creates a caption. The caption can then be used for generating alt-text.

The script does not need to be installed on your machine. The Python developer would run it directly from Google Colab.

DeepCrawl (a website intelligence platform) and Pythia work together to create captions. Further development makes new versions better and better at writing personalized alt-text.

Deep learning tools such as these were in the realm of science fiction even a few years ago. Thanks to Python-based machine learning, you can now employ them for free.

4. Redirect Audit

Redirects send users from one URL to another.

An experienced Python developer can develop a script to find redirect relevancy.
It is especially handy if you want to relaunch a website or have removed a large number of old pages and replaced them with new content.

Python script will crawl your site and divide the URLs into different categories.
Using the Python comparison tool, you can find which pages have content that is nearest to the old one.

The next and final step is to point old links to the new URL. Python can even do this part through proper implementation.

Internal linking tends to heavily focus on some articles. All articles are not equally informative. Some have more information. Internal linking concentrates on these pages and increases their importance. Pages with not very interesting material are left behind in search rankings.

Using Python, it is easy to build a pivot table to summarize the pages which have the most internal links.

Some of these can then be adjusted to point to less popular articles on your website.

This will ensure that Google understands there is valuable content not on a few pages but throughout the site. You can expect a search ranking boost after this exercise.

6. Keyword Research

The inclusion of keywords is a crucial aspect of SEO.

You can use Python very easily to find the right keywords.

All you need to do is use a hack on Google Suggest. Scrape all the Google Suggest results and save them in a JSON file.

Now use Python to create numerous variations of the seed keyword from the JSON file. Other developers have similar hacks using Google Trends in place of suggest.

Final Words

There are two steps to using Python for SEO:

  • Find out what can be automated.
  • Get an experienced Python developer to write the script for each function.

The astonishing fact is that most of it has been done and shared on repositories like GitHub. All that the Python developer you hire has to do is customize it to suit your site.

If you own a website you can, of course, do things the old-fashioned way, but why spend time and money on tasks that can be done while you are sleeping?
Python has proven its efficacy in technical SEO and driving site traffic.

It has proven value in mechanizing repetitive tasks that would need substantial resources to complete.

Using ML tools such as Pythia in SEO is just the beginning. In the future, the content quality evaluation will doubtless use Python-based ML tools.

It’s best to start now and use Python to explore how you can gain from deploying it.

Author Bio:

Justin D’Costa is an SEO specialist who works with Uplers, India's largest hiring platform that helps remote-first companies to hire top remote tech talent.

Justin is an absolute digital marketing geek having an experience of more than half a decade. He has vast knowledge in the field of SEO, PPC, Web Analytics, and Web Development that he likes to share through amazing articles.

When not wrapping his head around marketing, you can find him playing with his dog, Casper, or enjoying the beautiful nature by spending some time on the beach.