Back to Blog
Data Science

How to Scrape Facebook Comments from Posts & Reels for Sentiment Analysis

December 25, 2025
3 min read
S
By SociaVault Team
FacebookSentiment AnalysisWeb ScrapingCommentsPython

How to Scrape Facebook Comments from Posts & Reels for Sentiment Analysis

Likes are vanity. Comments are sanity.

If a brand posts a new product and gets 10,000 likes, that looks good. But if the top 50 comments are "This broke after 2 days" or "Customer service never replied," the brand is in trouble.

Sentiment Analysis is the process of quantifying this qualitative data.

  • Are people happy or angry?
  • What specific features are they complaining about?
  • Is the sentiment trending up or down?

To do this, you need the raw text of the comments. But Facebook makes exporting comments notoriously difficult. The Graph API requires you to be the admin of the page to see comments. You can't just scrape a competitor's page... officially.

In this guide, we'll show you how to use SociaVault to scrape comments from any public Facebook Post or Reel, and then analyze them.

Looking for Facebook data solutions? Check our Facebook API alternatives comparison.

The Challenge: Nested Replies & "View More"

Facebook comments are complex:

  1. Pagination: "View 50 more comments" buttons.
  2. Ranking: "Most Relevant" vs "All Comments".
  3. Threading: Replies are hidden inside comments.

A simple HTML scraper will fail because it can't click "View More". SociaVault's API handles this interaction on the server side.

Step 1: Get the Post URL

You need the URL of the post or Reel.

  • Post: https://www.facebook.com/Nike/posts/pfbid02...
  • Reel: https://www.facebook.com/reel/123456789...

Step 2: Scrape the Comments

We'll use the facebook/comments endpoint.

const API_KEY = 'YOUR_SOCIAVAULT_API_KEY';
const POST_URL = 'https://www.facebook.com/Nike/posts/pfbid02...';

async function getComments(url) {
  // We request 'ALL' to get hidden/spam comments too, or 'RELEVANT' for top ones
  const endpoint = `https://api.sociavault.com/v1/scrape/facebook/comments?url=${encodeURIComponent(url)}&filter=ALL`;
  
  const response = await fetch(endpoint, {
    headers: { 'Authorization': `Bearer ${API_KEY}` }
  });
  
  const data = await response.json();
  return data.comments;
}

Output Structure:

[
  {
    "id": "12345",
    "author": "John Doe",
    "text": "Love these shoes! But the shipping took forever.",
    "likes": 45,
    "date": "2025-11-25T10:00:00",
    "replies": [
      {
        "author": "Nike Support",
        "text": "Sorry to hear that, John! DM us."
      }
    ]
  }
]

Step 3: Sentiment Analysis (The Fun Part)

Now we have the text. Let's analyze it. You can use a simple library like vaderSentiment (Python) or an LLM API.

Simple Approach (Python + VADER)

from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer

analyzer = SentimentIntensityAnalyzer()

comments = [
    "Love these shoes! But the shipping took forever.",
    "Worst purchase ever. Do not buy.",
    "They are okay, nothing special."
]

for text in comments:
    score = analyzer.polarity_scores(text)
    print(f"Text: {text}")
    print(f"Compound Score: {score['compound']}") 
    # > 0.05 is Positive, < -0.05 is Negative
    print("---")

Advanced Approach (LLM)

For better accuracy (understanding sarcasm or context), send the comments to GPT-4-mini.

Prompt: "Analyze the sentiment of these 50 comments about a shoe launch. Categorize them into: Product Quality, Shipping, Price, and Customer Service. Give a sentiment score (1-10) for each category."

Use Case: Crisis Detection

Imagine you are monitoring a brand.

  1. Scrape comments from the latest post every hour.
  2. Calculate the ratio of Negative to Positive comments.
  3. Alert: If Negative comments spike > 20%, send a Slack alert to the PR team. "Potential Crisis Detected on Post #123".

Conclusion

Comments are the voice of the customer. By scraping them from Facebook Posts and Reels, you gain access to unfiltered feedback that you can't get from surveys or focus groups.

SociaVault makes the technical part easy, so you can focus on the analysis.

Start analyzing sentiment: Get your API Key

Found this helpful?

Share it with others who might benefit

Ready to Try SociaVault?

Start extracting social media data with our powerful API. No credit card required.