Facebook Comments Scraper
Pricing
from $2.00 / 1,000 results
Facebook Comments Scraper
Scrape comments from one or MANY Facebook post URLs in a single run. Returns comment text, author, likes, reply counts and timestamps, with each comment attributed back to the post URL it came from.
Pricing
from $2.00 / 1,000 results
Rating
0.0
(0)
Developer
code craker
Maintained by CommunityActor stats
0
Bookmarked
3
Total users
2
Monthly active users
a day ago
Last modified
Categories
Share
Extract comments from one or many Facebook posts in a single run. Paste a list of post URLs and get back structured data — comment text, author, likes, reply counts, timestamps — with every comment linked to the post it came from.
Features
- ✅ Batch scraping — pass many post URLs in one run instead of one run per post; comments are attributed back to their source post via the
postUrl/facebookUrl/inputUrlfields. - ✅ Works on posts, videos, reels and group permalinks.
- ✅ Replies (nested comments) — optionally expand reply threads (
includeReplies). - ✅ Comment ordering — scrape under Facebook's All comments, Most relevant or Newest first filter.
- ✅ Bring your own session or use the built-in one — paste your own Facebook cookies for a private, dedicated session, or leave it empty and use the actor's default shared session.
- ✅ Partial results are never lost — comments are saved to the dataset after each post, so a run that hits its time limit keeps everything scraped so far.
- ✅ Resilient to Facebook UI changes — comments are read from Facebook's own GraphQL data with a shape-tolerant parser, not from fragile CSS selectors.
- ✅ Drop-in compatible with integrations built against
apify/facebook-comments-scraper(samestartUrls/resultsLimitinput, same key output fields).
Input
{"startUrls": [{ "url": "https://www.facebook.com/nasa/posts/pfbid02..." },{ "url": "https://www.facebook.com/permalink.php?story_fbid=...&id=..." }],"maxComments": 50,"includeReplies": false,"sortComments": "all"}
| Field | Type | Default | Description |
|---|---|---|---|
startUrls | array | — | Post URLs as { "url": "..." } objects (or plain strings). Many posts per run are supported. |
postUrls | array | — | Alternative plain string list; merged with startUrls. |
maxComments | integer | 50 | Target number of comments per post (not total). resultsLimit is an accepted alias. |
includeReplies | boolean | false | Also expand and collect replies. includeNestedComments is an accepted alias. |
sortComments | string | "all" | all (recommended — surfaces the most comments), relevant, or newest. |
cookies | array | — | Your own Facebook session cookies (see Authentication). Leave empty to use the actor's default session. |
proxyConfiguration | object | Apify RESIDENTIAL | Keep residential — Facebook blocks most datacenter IPs. |
Output
One dataset item per comment:
{"id": "1234567890","commentId": "1234567890","text": "Great post!","date": "2026-07-01T10:20:30.000Z","timestamp": 1782642030,"likesCount": 12,"repliesCount": 3,"commentUrl": "https://www.facebook.com/.../posts/...?comment_id=...","postUrl": "https://www.facebook.com/nasa/posts/pfbid02...","facebookUrl": "https://www.facebook.com/nasa/posts/pfbid02...","inputUrl": "https://www.facebook.com/nasa/posts/pfbid02...","author": {"id": "100001","name": "Jane Doe","profileUrl": "https://www.facebook.com/jane","avatar": "https://..."},"profileId": "100001","profileName": "Jane Doe","profileUrl": "https://www.facebook.com/jane","profilePicture": "https://...","threadingDepth": 0,"parentCommentId": null,"isReply": false,"scrapedAt": "2026-07-03T12:00:00.000Z"}
postUrl / facebookUrl / inputUrl always echo the exact input URL the comment came from, so batched runs can be reliably split back per post.
Download the results as JSON, CSV, Excel or XML from the run's Dataset tab, or fetch them through the Apify API.
Authentication
Facebook hides most comments from anonymous visitors, so the scraper runs with a logged-in session. You have two options:
Option 1 — your own cookies (recommended)
You get a private session that is not shared with other users:
- Create or use a throwaway Facebook account — never your personal one. Disable 2FA on it.
- Log into that account in your browser.
- Export the cookies with a browser extension such as Cookie-Editor (Export → JSON).
- Paste the JSON array into the Facebook session cookies input field.
The export must include the c_user and xs cookies — those two carry the session.
Option 2 — default session (zero setup)
Leave the cookies field empty and the actor uses its built-in default session. This is the fastest way to try the actor, but the session is shared between all users, so it can be rate-limited or temporarily unavailable during busy periods. For production workloads, use your own cookies.
⚠️ Automated access can violate Facebook's Terms of Service and accounts used for scraping can get checkpointed or banned. Only scrape public data you are allowed to access, and use a dedicated throwaway account.
Usage tips
- Runtime: expect roughly 30–60 seconds per post (page load + comment expansion). Size your run timeout accordingly:
120 + 30 × number_of_postsseconds is a safe floor. - Memory: 4096 MB is the recommended run memory (a full Chrome browser runs inside the actor).
- Proxies: keep the default Apify RESIDENTIAL group. Datacenter IPs are widely blocked by Facebook and will produce empty results or login walls.
- Empty results? Check the
DEBUG_SCREENSHOTandDEBUG_HTMLkeys in the run's key-value store — they show exactly what the browser saw. The most common causes are expired cookies, a blocked proxy IP, comments turned off on the post, or a deleted/private post.
API / integration example
Using the Apify JavaScript client:
import { ApifyClient } from 'apify-client';const client = new ApifyClient({ token: 'YOUR_APIFY_TOKEN' });const run = await client.actor('YOUR_USERNAME/facebook-comments-scraper').call({startUrls: [{ url: 'https://www.facebook.com/nasa/posts/pfbid02...' },{ url: 'https://www.facebook.com/spacex/posts/pfbid02...' },],maxComments: 100,});const { items } = await client.dataset(run.defaultDatasetId).listItems();// Group comments back per post:const byPost = Map.groupBy(items, (c) => c.postUrl);
Migrating from apify/facebook-comments-scraper
This actor accepts the same core input (startUrls + resultsLimit / maxComments, includeNestedComments) and returns the same key output fields (id, text, date, likesCount, facebookUrl/postUrl/inputUrl, flat profileName/profileId author fields), so in most integrations you only need to change the actor ID.
FAQ
Why does a run need cookies at all? Facebook returns only a handful of comments (often none) to visitors who are not logged in. A session makes the full comment list available.
Can it scrape comments from private groups? Only if the account whose cookies you provide is a member of that group.
How many posts can I pass in one run? There is no hard limit — posts are processed sequentially in one browser session. For very large batches, split into runs of ~20–50 posts so each finishes within its timeout.
Does it collect personal data? Comments include public author names and profile URLs. You are responsible for using scraped data in compliance with GDPR/CCPA and other applicable laws.
Development
Built with the Apify SDK + Playwright.
apify login # onceapify push # build & deploy from this directory
Actor configuration for owners:
FB_COOKIES(secret env var) — the default session used when a user provides no cookies: a JSON cookie array or aname=value; name2=value2string.FB_EMAIL/FB_PASSWORD(secret env vars) — optional automated-login fallback; the resulting session is cached in a key-value store across runs.- Permission level (Console → Settings): works under both limited (default) and full permissions. Under limited permissions the login-session cache uses an actor-owned store (
facebook-comments-session); under full permissions it can share thefacebook-sessionstore with other actors of the owner.
How it works internally:
- Launches Playwright Chrome through a residential proxy and restores the Facebook session (input cookies →
FB_COOKIES→ cached login → automated login, failing fast with an actionable error when no auth exists). - Opens each post URL and listens to Facebook's
/api/graphqlresponses, extracting rawCommentnodes with a shape-tolerant JSON walker (no hardcoded payload paths). - Best-effort switches the ordering to "All comments", then repeatedly clicks "View more comments" (and reply expanders when enabled) and scrolls until the per-post target is reached or the feed runs dry.
- Pushes items to the dataset per post and updates the run status message with live progress.
- On failures or empty runs, saves
DEBUG_SCREENSHOTandDEBUG_HTMLto the run's key-value store.
Support
Found a bug or need a field added? Open an issue or email m83588864@gmail.com and we'll take a look.