How To Collect Data From Social Media?

If you are looking to work on a data science task where you want to analyze your social media data then you must be worried about how to collect data from your social media accounts. So, in this article, I will take you through how to collect data from social media.

How To Collect Data From Social Media?

Here are some of the popular social media accounts which are used that are used to analyze your data for any data science task such as Sentiment Analysis:

  1. Facebook
  2. Twitter
  3. WhatsApp
  4. Instagram

Now let’s have a look at each of these social media platforms to learn how to collect data from them.

Facebook:

The data collected from Facebook can be used for the task of sentiment analysis as it is a free speech platform and everyone is allowed to share their opinions on any topic. Here are the steps that you need to follow to collect data from your Facebook account:

  1. Go to settings & privacy
  2. Then go to settings
  3. From the left click on Your Facebook Information
  4. Click on view at Download your information
  5. Then only select posts and click on create file.

The data will be downloaded and you can explore your data. Just for saving your time, I will recommend you to find the ā€œyour_posts_1.jsonā€ file from the dataset downloaded from your Facebook account if you want to work on the task of sentiment analysis. Here is an example of how you can use your data downloaded from your Facebook account.

Twitter:

Twitter is an amazing data source for working on any data science task. But collecting data from Twitter is not as easy as collecting data from Facebook as to get data from Twitter you must have the Twitter API. So here are the steps you need to follow to get data from Twitter:

  1. Go toĀ https://developer.twitter.com/en/apps.
  2. Sign in to your Twitter account.
  3. Then click on create new app.
  4. Then enter the name of your project, a good description.
  5. Then agree to the terms and conditions and then click on create.
  6. You will get to see your consumer key and the consumer secret note it somewhere as you will need it in future (all the steps above were followed to get your consumer key and consumer secret).
  7. Then you have to install a Python library “twython”, which can be easily installed using the pip command; pip install twython.

Then you have to use your consumer key and consumer secret as shown below:

WhatsApp:

The data collected from WhatsApp can be used for analyzing chats between two people or a group chat also. You can analyze WhatsApp chats for tasks such as sentiment analysis, topic modelling etc. Now below are the steps that you have to follow to collect data from WhatsApp:

  1. Open any chat or any group chat
  2. Click on the 3 dots above
  3. Select more and then select export chat
  4. You will get options whether you want to include media or not so it is preferable to exclude media.

Instagram

The Instagram data can be used to analyze which type of posts get a higher reach on Instagram which is very useful for a company that wants to sell services on a social media platform. Here are the steps that you need to follow to get your data from Instagram:

  1. Go to your profile and click on settings
  2. Then go to privacy and security
  3. In the end, you will see the second last option as “Data Download”
  4. Below that option, you will see “Request Download”, click on it and follow the steps.

Summary

So in this article, I introduced you to how you can collect your data from social media accounts such as Facebook, Instagram, Twitter, and WhatsApp. I hope you liked this article on how to collect data from social media for data science tasks. Feel free to ask your valuable questions in the comments section below.

Aman Kharwal
Aman Kharwal

I'm a writer and data scientist on a mission to educate others about the incredible power of datašŸ“ˆ.

Articles: 1498

Leave a Reply