Back to Blog
Facebook

Scrape Facebook Comments for Sentiment Analysis (Posts & Reels)

December 25, 2025
5 min read
S
By SociaVault Team
FacebookSentiment AnalysisCommentsBrand MonitoringPython

Scrape Facebook Comments for Sentiment Analysis (Posts & Reels)

Likes are vanity; comments are sanity. A product post can rack up 10,000 likes and still be a quiet disaster if the top comments are "broke after two days" and "support never replied." The likes look great in a screenshot; the comments are where the truth is. Turning that pile of qualitative text into something you can act on is what sentiment analysis is for — are people happy or angry, about what specifically, and is it trending the wrong way?

The hitch with Facebook is access. The official Graph API basically requires you to be the page admin to read comments, so you can't analyze a competitor's post officially. This guide scrapes comments from any public post or reel and runs sentiment analysis — first with a fast local tool (VADER), then with an LLM for nuance. Code in JavaScript and Python.

Step 1: Scrape the comments

The post-comments endpoint takes the post or reel url and a cursor for paging deeper.

const API_KEY = process.env.SOCIAVAULT_API_KEY;
const BASE = "https://api.sociavault.com/v1/scrape/facebook";

async function getComments(postUrl, cursor) {
  const params = new URLSearchParams({ url: postUrl });
  if (cursor) params.set("cursor", cursor);
  const res = await fetch(`${BASE}/post/comments?${params}`, {
    headers: { "x-api-key": API_KEY },
  });
  const json = await res.json();
  if (!json.success) return [];
  // Log json.data once to confirm the comments array + field names.
  return json.data.comments || [];
}

The API handles the "view more comments" pagination server-side — you just keep passing the cursor. A simple HTML scraper can't do that, which is the whole reason this is hard to do yourself.

Step 2: Fast sentiment with VADER (Python)

VADER is a lightweight, rule-based sentiment analyzer that's genuinely good for short social text. Perfect for a first pass over thousands of comments.

from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer

analyzer = SentimentIntensityAnalyzer()

def classify(comments):
    pos = neg = neu = 0
    for c in comments:
        text = c.get("text") or c.get("message", "")
        score = analyzer.polarity_scores(text)["compound"]
        if score >= 0.05: pos += 1
        elif score <= -0.05: neg += 1
        else: neu += 1
    return {"positive": pos, "negative": neg, "neutral": neu}

# comments = output of your scrape, as a list of dicts
# print(classify(comments))

A compound score above 0.05 is positive, below -0.05 negative. Run it across a post's comments and you've got a quick happiness ratio.

Step 3: Nuanced sentiment with an LLM

VADER misses sarcasm and context ("oh great, another delay 🙄" reads positive to it). When you need accuracy and categorized feedback, hand the comments to an LLM:

"Here are 50 comments on a product launch. Group the feedback into Product Quality, Shipping, Price, and Support, and give each a 1–10 sentiment score with one representative quote."

You get a structured report you can forward straight to the product or PR team — far more useful than a single happy/sad number.

The killer use case: crisis detection

The reason to automate this rather than spot-check: early warning. Scrape the comments on your brand's latest posts on a schedule, compute the negative ratio, and alert when it spikes.

function negativeRatio(classified) {
  const total =
    classified.positive + classified.negative + classified.neutral || 1;
  return classified.negative / total;
}

// if (negativeRatio(result) > 0.2) sendSlackAlert("⚠️ Negativity spike on latest post");

A sudden jump in negative comments after a launch or an outage is exactly the thing you want to know about in minutes, not when it's trending. This turns your comments section into a smoke alarm.

Frequently Asked Questions

Can you scrape comments from a Facebook post you don't own?

Yes, from any public post or reel — pass its URL to a comments endpoint. This is different from the official Graph API, which generally requires page-admin access to read comments, meaning you can't analyze competitor posts officially. Scraping public comments fills that gap.

How do I handle "view more comments" pagination?

Pass the cursor from each response back into the next request to page deeper, until you've collected enough. The API expands the hidden comments server-side, so you don't need browser automation to click "view more" — a common failure point for DIY HTML scrapers.

What's the difference between VADER and LLM sentiment analysis?

VADER is fast, free, and rule-based — great for a first pass over thousands of comments — but it misses sarcasm and context. An LLM understands nuance and can categorize feedback (quality, shipping, price, support), at higher cost and latency. Use VADER to triage, an LLM for the report.

Can I detect a PR crisis automatically?

Yes — scrape your latest posts' comments on a schedule, compute the negative-to-total ratio, and alert (e.g., to Slack) when it crosses a threshold. A negativity spike after a launch or outage is an early signal worth catching in minutes rather than hours.

Reading publicly visible comments is standard practice for brand monitoring and research. Stay on public posts, respect rate limits, avoid private content, and handle any personal data responsibly under applicable privacy laws.

Does it work on Reels too?

Yes — pass a reel URL the same way you would a post URL. Reels often have very active comment sections, which makes them a rich source for sentiment on newer content formats.

The bottom line

Comments are the unfiltered voice of your customers, and Facebook makes them hard to export — which is exactly why scraping them is worth it. Pull them from any public post, triage with VADER, deep-dive with an LLM, and wire up a negativity alert so a brewing crisis reaches you early.

Want to analyze the sentiment? Start free with SociaVault with 50 credits.

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.