Using Python for Technical SEO: What You Need to Know

in #weight6 years ago (edited)

Python has been receiving a lot of attention within the SEO community recently.

So, being the curious technical SEO that I am, I started looking into why and before I knew it, I was deep into learning and applying it.

It’s fair to say that I have fallen in love with the language over the past few months that I have been learning it and want to share it with everyone, to show how it can help automate SEO tasks.

I’m not a data scientist and I don’t have a computer science background, but the beauty of Python is you don’t need to have experience in either of these things in order to understand and start using it.

What Is Python?
In short, Python is an open-source, object-oriented interactive programming language that is interpreted line by line.

With simple and easy to learn syntax, as well as advanced readability and support for a number of modules and libraries, Python is well-loved due to the increased productivity it provides.

As a testament to this, Python is used by some of the biggest organizations in the world to power their platforms, perform data analysis, and run their machine learning models.

Companies including Google, YouTube, Netflix, NASA, Spotify, and IBM have publicly stated Python has been an important part of their growth, due to its simplicity, speed, and scalability.

In fact, Google’s first web-crawler was actually written in Python and it remains one of their official server-side languages.

How to Run Python
You can run Python scripts in a number of ways, depending on what works best for you.

Most systems come with Python already installed, although it’s worth noting that this will more than likely be Python 2, which will be officially deprecated in 2020 now that Python 3 is deemed stable.

You can run Python from your terminal or command line IDE (Integrated Development Environment) or use cloud-based alternatives including:

Jupyter Notebooks.
Google Colab.
These provide an easier experience for beginners to learn and test elements of code line by line.

Python Libraries
The main power of Python is in its libraries, which enable a number of add-ons including:

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

Some useful libraries for tasks involving data analysis and automation include:

TensorFlow: An open-source machine learning library.
NumPy: Useful for scientific computing.
SciPy: Used for scientific and technical computing.
SciKit Lear: Machine learning for data mining and analysis.
Pandas: Used for data manipulation and analysis.
SpaCy: A great natural 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 power the websites we work on (such as HTML, CSS, and JavaScript) is important, Python provides many automation opportunities for low-level tasks which we would usually spend several hours undertaking.

Python empowers SEO professionals in a number of ways as it not only enables us to automate repetitive tasks, but also to extract and analyze large data sets.

The amount of data marketers work with is only increasing, so being able to efficiently analyze this will help to solve many complex problems in a shorter amount of time.

This in turn saves valuable time and allows us to be more efficient in undertaking other important SEO tasks.

These factors combined have led to a growth in the popularity of Python amongst SEO professionals.

The ability to better understand data will not only help us do our jobs better, but will also allow us to make data-driven decisions.

These decisions will then enable us to provide concrete insights for our clients and stakeholders and have more confidence in the recommendations we implement.

Automating with Python
While Python will not be able to imitate human, emotion-led strategy, Python scripts can be used to automate a large number of time-consuming tasks.

This list of tasks you can automate with Python is growing continuously:

Identifying user intent.

Mapping URLs ahead of a migration.
Internal link analysis.
Performing keyword research.
Optimizing images.
Scraping websites.
Example Scripts to Try

Ready to get started with Python?

Here are a few useful scripts which I have been exploring recently, along with a brief description of how each one works and the challenges they solve.

Image Captioning with Pythia
This is the first script that introduced me to the language and the one that kick-started my desire to learn.

Using Pythia, which is a modular deep learning framework created by Facebook, this script generates a caption for an image URL.

This caption can then be used for images currently missing alt tags, which are important for accessibility and image search.

The script is based upon the bottom up and top down mechanism, which calculates results by focusing attention on different elements within an image.

For each word generated, attention is weighted to individual pixels within the image, outlining the region with the maximum attention.

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

Once a copy of the necessary code is saved to your personal Google Colab drive, all cells can be run, performing each step for you.

This will download the data sources needed to run the process, as well as automatically completing all of the steps that would typically need to be undertaken manually.

For example, all libraries will be installed, classes will be created and functions assigned.

This will generate an area to add in your image URL and a button to caption the image.

A caption will then be provided for each image, which can be directly used as an alt tag, or to inspire the creation of one.

Hamlet Batista has written a comprehensive guide to generate text from images with Python which shows this script in action.

SEO Analyzer
I found this SEO Analyzer script, created by Seth Black, on GitHub, which is used to analyze the structure of a site by crawling it and providing an analysis of the basic SEO issues.

It requires Python 3.4 or above, as well as the BeautifulSoup and urllib packages. Once installed you can then crawl a website from the homepage or XML sitemap.

Once it has finished crawling the site it will display data including word count, page titles, and meta descriptions as well as warnings, where applicable, for missing titles, meta descriptions and alt text.

Image Optimizer
Another GitHub find is this script, created by Victor Domingos, which is written in pure Python and is used to reduce the file size of images.

It requires Python 3.6 or above, as well as the Pillow library, in order to run.

Once installed you will be able to optimize either a single image or a folder with multiple images, using the appropriate string detailed in the GitHub repository.

It is worth noting that this script does optimize images destructively, so it’s recommended that you save a copy before running the operation.

Read Complete Article Here: https://www.searchenginejournal.com/python-technical-seo/330515/?ver=330515X3

Coin Marketplace

STEEM 0.19
TRX 0.15
JST 0.029
BTC 63964.02
ETH 2592.87
USDT 1.00
SBD 2.75