Scrape profile pictures from multiple facebook ID’s


Home » Blog » Others » Scrape profile pictures from multiple facebook ID’s

Facebook graph API is excellent tool for scrape the facebook data. Unfortunately the token has 1 hour expiration time and no more than 400-500 request can be done with a single token. If you have around 50 k facebook ID and wanted to extract all the profile picture then there is one trick through which it all can be extracted within an hour.

To scrape such huge data, the grouping option has to be use in the facebook. Ok let’s get started. I have around 40 k of data which has facebook ID and the name in the csv file

Now I need to download all the profile images of these facebook ID’s. So first go to the facebook developer page and get token from

Now let’s start our main function code in python.

Here is the main function. It extract all the ids from my csv file ids.csv . After that it chunks all the data of the array in the size of 10. The chunks function is not ready yet so let’s write the chunk function.

After the chunk function, it chunks the data for the size we provided and now we can join the entire array with comma separated value and pass them in our main getdata function

In this method there is a url which is a form of the graph API. We pass the ids of the facebook like id1,id2,id3 …. With the help of this grouping option, around 40-50 ids data can be extracted with a single request. I have extracted around 40 k of data within 2 hours using this way.

Hope it helps for someone who wants to extract a lot of profile pictures from facebook.

About Author