An Introduction to Python for Technical SEO

Python has been receiving quite a lot of consideration inside the SEO neighborhood lately.

So, being the curious technical SEO that I’m, I began trying into why and earlier than I knew it, I used to be deep into studying and making use of it.

It’s truthful to say that I’ve fallen in love with the language over the previous few months that I’ve been studying it and need to share it with everybody, to present the way it can assist automate SEO duties.

I’m not a knowledge scientist and I don’t have a pc science background, however the fantastic thing about Python is you don’t want to have expertise in both of these items so as to perceive and begin utilizing it.

What Is Python?

In brief, Python is an open-source, object-oriented interactive programming language that’s interpreted line by line.

With easy and straightforward to be taught syntax, in addition to superior readability and help for plenty of modules and libraries, Python is well-loved due to the elevated productiveness it gives.

As a testomony to this, Python is utilized by a number of the greatest organizations on this planet to energy their platforms, carry out knowledge evaluation, and run their machine studying fashions.

Companies together with Google, YouTube, Netflix, NASA, Spotify, and IBM have publicly said Python has been an necessary a part of their development, due to its simplicity, pace, and scalability.

In truth, Google’s first web-crawler was really written in Python and it stays certainly one of their official server-side languages.

How to Run Python

You can run Python scripts in plenty of methods, relying on what works greatest for you.

Most programs include Python already put in, though it’s price noting that it will greater than probably be Python 2, which can be formally deprecated in 2020 now that Python Three is deemed steady.

You can run Python out of your terminal or command line IDE (Integrated Development Environment) or use cloud-based options together with:

These present a better expertise for newcomers to be taught and take a look at components of code line by line.

Python Libraries

The fundamental energy of Python is in its libraries, which allow plenty of add-ons together with:

  • Data extraction.
  • Analysis and preparation.
  • Scientific computing.
  • Natural language processing.
  • Machine studying.

Some helpful libraries for duties involving knowledge evaluation and automation embody:

  • TensorFlow: An open-source machine studying library.
  • NumPy: Useful for scientific computing.
  • SciPy: Used for scientific and technical computing.
  • SciKit Lear: Machine studying for knowledge mining and evaluation.
  • Pandas: Used for knowledge manipulation and evaluation.
  • SpaCy: An excellent pure language processing library.
  • Requests: A library for making HTTP requests.

How Python Can Help with Technical SEO

While having an understanding of the languages which energy the web sites we work on (resembling HTML, CSS, and JavaScript) is necessary, Python gives many automation alternatives for low-level duties which we’d normally spend a number of hours enterprise.

Python empowers SEO professionals in plenty of methods because it not solely permits us to automate repetitive duties, but additionally to extract and analyze massive knowledge units.

The quantity of information entrepreneurs work with is barely growing, so having the ability to effectively analyze it will assist to remedy many advanced issues in a shorter period of time.

This in flip saves useful time and permits us to be extra environment friendly in enterprise different necessary SEO duties.

These elements mixed have led to a development within the recognition of Python amongst SEO professionals.

The potential to higher perceive knowledge won’t solely assist us do our jobs higher, however will even enable us to make data-driven choices.

These choices will then allow us to present concrete insights for our shoppers and stakeholders and have extra confidence within the suggestions we implement.

Automating with Python

While Python won’t be able to imitate human, emotion-led technique, Python scripts can be utilized to automate numerous time-consuming duties.

This listing of duties you’ll be able to automate with Python is rising constantly:

  • Identifying person intent.
  • Mapping URLs forward of a migration.
  • Internal hyperlink evaluation.
  • Performing key phrase analysis.
  • Optimizing pictures.
  • Scraping web sites.

Example Scripts to Try

Ready to get began with Python?

Here are a number of helpful scripts which I’ve been exploring lately, together with a quick description of how each works and the challenges they remedy.

Image Captioning with Pythia

This is the primary script that launched me to the language and the one which kick-started my want to be taught.

Using Pythia, which is a modular deep studying framework created by Facebook, this script generates a caption for a picture URL.

This caption can then be used for pictures presently lacking alt tags, that are necessary for accessibility and picture search.

The script is predicated upon the underside up and prime down mechanism, which calculates outcomes by focusing consideration on totally different components inside a picture.

Pythia Mechanism

For every phrase generated, consideration is weighted to particular person pixels inside the picture, outlining the area with the utmost consideration.

The ease of this script is due to the truth that it may be run straight from Google Colab and requires no direct coding.

Once a replica of the mandatory code is saved to your private Google Colab drive, all cells will be run, performing every step for you.

This will obtain the information sources wanted to run the method, in addition to routinely finishing the entire steps that might usually want to be undertaken manually.

For instance, all libraries can be put in, lessons can be created and features assigned.

Pythia Captioning Cells

This will generate an space to add in your picture URL and a button to caption the picture.

Pythia Image Captioning

A caption will then be supplied for every picture, which will be straight used as an alt tag, or to encourage the creation of 1.

Pythia Image Captioning Example

Hamlet Batista has written a complete information to generate textual content from pictures with Python which reveals this script in motion.

SEO Analyzer

I discovered this SEO Analyzer script, created by Seth Black, on GitHub, which is used to analyze the construction of a website by crawling it and offering an evaluation of the fundamental SEO points.

It requires Python 3.four or above, in addition to the LovelySoup and urllib packages. Once put in you’ll be able to then crawl a web site from the homepage or XML sitemap.

Once it has completed crawling the positioning it’ll show knowledge together with phrase rely, web page titles, and meta descriptions in addition to warnings, the place relevant, for lacking titles, meta descriptions and alt textual content.

SEO analyzer example

Image Optimizer

Another GitHub discover is that this script, created by Victor Domingos, which is written in pure Python and is used to scale back the file dimension of pictures.

It requires Python 3.6 or above, in addition to the Pillow library, so as to run.

Once put in it is possible for you to to optimize both a single picture or a folder with a number of pictures, utilizing the suitable string detailed within the GitHub repository.

It is price noting that this script does optimize pictures destructively, so it’s advisable that you just save a replica earlier than operating the operation.

Image Compression Example

In this instance, the picture I ran via the script was lowered by 5%, reducing the file dimension from 2.eight MB to 2.6 MB.

As you’ll be able to see under, there is no such thing as a seen distinction between the unique and optimized pictures.

Even this 5% discount in weight on a web page can have a big impression on the efficiency.

Image Compression Original and Optimised

Other Possibilities

These three examples are simply scratching the floor, there are various extra automation and optimization prospects utilizing Python scripts, together with:

  • Internal linking evaluation.
  • Log file evaluation.
  • Hreflang validation.
  • Keyword development calculation.
  • Collecting GSC knowledge.
  • Performing competitor evaluation.

Powering Machine Learning

Python can also be a well-liked language used to energy machine studying purposes due to its easy, intuitive and accessible syntax.

It can also be open-source, with a number of developer advocates offering help for customers.

In addition, there are numerous helpful libraries that are useful when working with and coaching machine studying fashions.

What Is Machine Learning?

Machine studying is actually “an application of artificial intelligence that provides systems with the ability to automatically learn and improve from experience, without the need to be explicitly programmed” (a full definition will be discovered right here).

Machine studying is often used to establish patterns in knowledge, upon which predictions can then be made.

Python & Machine Learning

Run along side machine studying, Python can be utilized to energy scripts for coaching a dataset, earlier than it summarizes and visualizes the information.

From right here, the mannequin will consider the algorithms to allow predictions to be made.

Real-World Machine Learning Examples

The use of machine studying on the internet is growing on a regular basis, with new fashions being created and coaching knowledge turning into extra accessible every day.

Some real-world machine studying examples embody:

  • Google’s RankBrain algorithm.
  • Baidu’s Deep Voice program.
  • Twitter’s curated timelines.
  • Netflix and Spotify suggestions.
  • Salesforce’s Einstein function.

SEO Possibilities with Machine Learning

Due to their potential to remedy advanced issues, it’s no shock that machine studying fashions are getting used to assist make entrepreneurs’ lives simpler.

As Britney Muller says:

“Machine Learning is becoming more accessible and will free us up to work on higher-level strategy.”

This will allow you to spend extra time discovering options, somewhat than simply figuring out issues.

Some examples of machine studying fashions utilized in SEO embody:

  • Content high quality analysis.
  • Identifying key phrase gaps and alternatives.
  • Gaining insights into person engagement.
  • Optimizing title tags.
  • Automating meta description creation.
  • Transcribing audio.

Google’s NLP Model

One such mannequin price trying out is Google’s Natural Language Processing API, which makes use of machine studying to reveal the construction and that means of textual content. It analyzes textual content to perceive the sentiment, in addition to extract key info.

Not solely does this API enable you to prepare a mannequin personalised to your content material, offering outcomes which might be related to your particular wants, additionally, you will achieve an perception into Google’s understanding of your content material.

Google NLP Sentiment ExampleGoogle NLP Syntax Example


I hope this has impressed you to begin studying Python and discover the way it can assist you with automating duties and analyzing advanced knowledge so as to enhance your effectivity.

To end, I wished to share my three greatest ideas for getting began and persevering with to be taught:

Tip 1: Talk to Your Developers

There’s a excessive likelihood the builders you’re employed with can have an understanding of Python.

Have a dialog with them, allow them to know what you’re engaged on and spark their curiosity too – there might even be one thing you’ll be able to collaborate on!

Tip 2: Join Communities

One of the perfect issues about studying Python is the help accessible, there are such a lot of on-line communities (resembling this one) with a whole lot of supportive people keen to present non-judgmental recommendation.

Tip 3: Keep Practicing & Have Fun

This is crucial piece of recommendation a developer good friend gave to me.

There is not any stress to grow to be a Python grasp in weeks.

Take your time to be taught the language and begin enjoyable aspect initiatives to put what you’re studying into observe.

Some nice sources which helped me get began embody:

More Resources:

Image Credits

All screenshots taken by creator, October 2019

Tags: , , ,