How to get the Alexa Rank of a site with Python

Alexa Rank value with python - SEO Scripting

The Alexa Ranking

The Alexa Internet Inc., known to all as Alexa, is a company of the United States associated with the group. This company is known to all practitioners of the web for a particular value called Alexa Rank. This value is no more than an indicator that should indicate a website traffic. In particular it should be an indicator of the popularity of a site.

Alexa Rank value with python - SEO Scripting

To get this value, you must first have signaled the site to Alexa, otherwise you will not give any value. Then over time Alexa will collect your site traffic data. Every time you will be interested to traffic, you can visit the official website (see here) and make a request of rank.

In my case I got this

Alexa Ranking with Python - SEO scripting

As you can see, the lower is the rank value the better is the traffic. In fact, the ranking is nothing more than the site’s ranking in a hypothetical world rankings where the first place is the busiest site in the world. (By the way … you already know what is…Google … what do you expect? ;).

In addition visiting the site, you can also see a graph that shows the historical trend of the rankings in the various months of the year.

Interesting is to see that there is also the ranking of your own nationality.

The SEOLIB Python Library

The Python programming language is so well suited to data analysis that could be an excellent solution for creating scripts that will help tremendously those who carry out SEO activities or webmastering. In this regard a specific library exists in PyPI repository (where all the Python libraries) are available. This library provides a number of useful tools
for this kind of activity. This library is called seolib.

To install it on your computer, you have to type from the command line the following command.

pip install seolib

Then, once you have opened a Python session, you can import the module.

import seolib

You can also import it directly in programs written with Python if you plan to carry out more complex operations.

How to get the Alexa Rank value of a specific site

In order to obtain the Alexa Rank of a site, the seolib library provides the get_alexa () function that takes one argument, the URL of the site you want to analyze:

import seolib as seo

alexa_rank = seo.get_alexa('')

You will get the value of ranking stored in the alexa_rank variable, which in my case is



If you are interested in more information about the seolib library, and its functions, I recommend you to read the official documentation (see here). Otherwise you will find more information and tutorials within the Python section of the Meccanismo Complesso site, in particular looking for the SEO & Webmastering (see here).[:]

Leave a Reply