How to get the number of Facebook Likes with Python

SEO metrics – Facebook Likes

Among the SEO metrics it is often useful to know how many of Facebook Likes are recognized for a particular site, or in more depth for a particular page that has been linked (either by the person concerned, but also by others) in some posts on Facebook. Often the popularity of a page, or rather its appreciation, may be a very good indicator, if not a metric SEO, to know the success or failure of a campaign or a particular post.

SEO - Facebook Likes get the number with Python

SEOLIB – a useful library for SEO

Python is a programming language that lends itself well to data analysis. Moreover, the ease with which you can write a script and use it as a great tool for doing SEO investigations, makes it a great tool for anyone who carries out an activity of webmastering or marketing surveys. Python is a very useful language in this regard, because of the extensive number and variety of libraries that allow you to apply it in many areas. In PyPI repository (where available all the Python libraries) there is a library that provides a number of useful tools for SEO. This library is called seolib.

To install it on your computer, you have to write the following command from a command line:

 

Then once you have installed the seolib package, you can import the module directly within a Python session.

You can import the seolib module within the code too, if you need to perform more complex tasks.

How to get the Facebook Likes with seolib

To obtain the number of Facebook Likes assigned to particular site, the seolib library provides the get_facebook_likes () function that takes one argument, the URL of the site you want to analyze:

if you execute the code you will get the number of likes assigned to the Meccanismo Complesso web site.

But you might also be interested in the number of likes assigned to a particular page of your site, in this case, you have to extend the URL passed as an argument including the whole URL of the page

Finally, you can also get the likes directly assigned to any page, post or image  posted on Facebook (if you are not using the Web sites for promotion).

Conclusions

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.