Follow Gregory Piatetsky, No. 1 on LinkedIn Top Voices in Data Science & Analytics

KDnuggets Home » News » 2015 » Jun » Tutorials, Overviews, How-Tos » How to Visualize your Facebook Network ( 15:n20 )

How to Visualize your Facebook Network


Recent restrictions to Facebook API has made it difficult to visualize it readily. But, here you can find a complete pipeline from collecting data, storing it and finally visualizing it as network graph.



By Co-founder at Linkurious.

Facebook knows the social network of more than a billion persons. If you are a Facebook user though, you have little tools to explore your own social network. We are going to see how, with a few scraping tools, a Neo4j graph database and Linkurious, we can visualize our Facebook network.

There is no easy solution to visualize your Facebook network. Facebook is restricting access to its API. As a result, Netvizz, an application to visualize one’s Facebook network, was recently discontinued. Visualizing your Facebook network has become hard.

Hervé Piedcoq, data analyst and OSINT expert is going to show you a method to 1) collect, 2) store and 3) visualize your Facebook network.

Collecting the data to build your Facebook network

1st step : download your friends’ list

We will use OutWit Hub, a powerful yet easy to use scraper, based on Mozilla and XUL. It has built-in functionalities such as table and list detection, an extractor engine based on the source code of a web page, macros and job tools.

We could, of course, use Python or other languages to a scrape Facebook, but OutWit Hub is clearly non-programmer oriented and immediately operational.

Connect to your account via OutWit Hub and display the complete list of your friends.

Visualizing your friends via Outwit.

Visualizing your friends via Outwit-hub.

OutWit Hub uses the source code of the webpage to scrape the data. The problem is that Facebook uses a lot of Javascript that pollutes the code and really makes it hard to analyze.

A good way to avoid this issue, is to save this webpage in HTML on your hard disk and open it as a static page in OutWit Hub.

On the left panel, click on “links” (“Liens” in french), to grab all the links present on this page.

outwit-with-data

Extract the links.

Filter these links using this regex in the bottom left corner box : Now export the selection to a csv file. Simply replace the values in the column Url Source, with your profile ID, and rename it “Source”. Rename Url Page as “Target”.

At this point, if you imported this file in a graph visualizer of your choice, you would obtain something like that :

Using Gephi to visualize our Facebook network.

Using Gephi to visualize our Facebook network.

This graph is nice, as you get an instant view on the list of your friends, but not really interesting in terms of social network analysis. What is lacking is the relationships between your friends.

2nd step: clean your list and export it to html

For this part, we are going to use Openrefine in order to clean up a little bit the URLs. Your data should look like this:


Sign Up