# Facebook Posts/Comments Scraper (`alien_force/facebook-posts-comments-scraper`) Actor

Facebook Post Scraper with Comments extracts Facebook post details, including text, author info, likes, shares, and media. It also scrapes comments with user details, engagement metrics, and timestamps. Ideal for social media monitoring, sentiment analysis, and audience insights.

- **URL**: https://apify.com/alien_force/facebook-posts-comments-scraper.md
- **Developed by:** [Alien Force](https://apify.com/alien_force) (community)
- **Categories:** Social media, Videos
- **Features:** Limited permissions
- **Stats:** 866 total users, 30 monthly users, 100.0% runs succeeded, 19 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $6.40 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Facebook Post Scraper with Comments

### 📌 Introduction

**Facebook Post Scraper with Comments** is a powerful and efficient Apify actor designed to scrape **Facebook posts** along with their **comments**. This tool allows you to extract valuable data, including post details, reactions, images, videos, and comments, helping you analyze engagement and user interactions.

### 🚀 Key Features

- 🔍 **Scrape Facebook Posts** – Extracts details such as text, author info, likes, comments, and shares.
- 💬 **Retrieve Post Comments** – Collects user comments, including author details, engagement counts, and timestamps.
- 📸 **Media Extraction** – Fetches images and videos attached to posts and comments.
- ⏳ **Customizable Wait Times** – Set min/max wait times for requests.
- 🍪 **Supports Cookies** – Allows adding Facebook cookies for authenticated scraping.

### 🔗 Use Cases

- 📝 **Social Media Monitoring** – Analyze public discussions and trends.
- 📊 **Brand Sentiment Analysis** – Track reactions and engagement on brand posts.
- 🏆 **Influencer Research** – Extract data from influencer posts and comments.
- 🔍 **Market Research** – Gather insights on trending topics and audience behavior.

### 🔧 Input Schema

The actor accepts the following **JSON** input structure:

```json
{
    "post_urls": [
        {
            "url": "https://www.facebook.com/thewitcherfanclub/posts/pfbid02reBdcEgYdgLLP92A7ZJ6KLPcNq3LHha9TjYi2k2ytbeS2q2rxkhCqAWy2m6j3TkRl"
        }
    ],
    "fetch_reaction_map": false,
    "comments_limit": 5,
    "min_wait_time_in_sec": 1,
    "max_wait_time_in_sec": 4,
    "cookies": [],
    "proxyConfiguration": {
        "useApifyProxy": true
    }
}
```

### 📤 Output Schema

The output will be an array of scraped posts and comments in the following JSON format:

```json
{
    "input": "https://www.facebook.com/reel/1397741784161219",
    "author": null,
    "post_id": "1397741784161219",
    "action_id": "ZmVlZGJhY2s6NzU0NTY5MTA2NzEyMTkx",
    "text": "Cette voix 🤩\nTeddy Swims est venu interpréter dans nos studios son titre \"Lose Control\" 🎤",
    "create_time": 1703340048000,
    "post_url": "https://www.facebook.com/reel/1397741784161219",
    "like_count": 26607,
    "comment_count": 1616,
    "share_count": 9,
    "view_count": 4000000,
    "reaction_map": [],
    "play_count": 4000000,
    "image_list": [],
    "video_list": [
        "https://video.fcai20-2.fna.fbcdn.net/o1/v/t2/f2/m366/..."
    ],
    "video_cover_image": [
        "https://scontent.fcai20-4.fna.fbcdn.net/v/t15.5256-10/..."
    ],
    "durationInSec": [221.92],
    "type": "video",
    "author_username": "Skyrock",
    "author_user_id": "100064773248135",
    "author_profile_url": "https://www.facebook.com/SkyrockFM",
    "author_avatar": "https://scontent.fcai20-5.fna.fbcdn.net/v/t39.30808-1/...",
    "comments": []
}
```

**Note:** The `reaction_map` field contains reaction breakdown data when `fetch_reaction_map` is enabled. It is an array of objects with `name`, `count`, and `parsed_count` properties. Example:

```json
{
    "reaction_map": [
        {
            "name": "Like",
            "count": 166,
            "parsed_count": "166"
        },
        {
            "name": "Love",
            "count": 19,
            "parsed_count": "19"
        },
        {
            "name": "Haha",
            "count": 5,
            "parsed_count": "5"
        }
    ]
}
```

# Actor input Schema

## `post_urls` (type: `array`):

Add Facebook post urls to scrape posts

## `fetch_reaction_map` (type: `boolean`):

When turned on, reaction map is fetched for each post of type `video` only. Regular post items are always fetched regardless of this setting.

## `comments_limit` (type: `integer`):

Limit number of comments

## `min_wait_time_in_sec` (type: `integer`):

Minimum seconds to wait for each cursor.

## `max_wait_time_in_sec` (type: `integer`):

Maximum seconds to wait for each cursor.

## `proxyConfiguration` (type: `object`):

Configure proxies to be used by the crawler.

## Actor input object example

```json
{
  "post_urls": [
    {
      "url": "https://www.facebook.com/thewitcherfanclub/posts/pfbid02reBdcEgYdgLLP92A7ZJ6KLPcNq3LHha9TjYi2k2ytbeS2q2rxkhCqAWy2m6j3TkRl"
    },
    {
      "url": "https://www.facebook.com/watch/?v=500165819136200"
    },
    {
      "url": "https://www.facebook.com/100063521621753/posts/1128544229272954"
    },
    {
      "url": "https://www.facebook.com/SkyrockFM/videos/nawell-madani-pie%CC%80ge-soprano-/375768715295270/"
    },
    {
      "url": "https://www.facebook.com/reel/1397741784161219"
    },
    {
      "url": "https://www.facebook.com/SpiroSpathisEG/posts/pfbid02J7rXJA5ZmmUPcYvxHDKe1VtVLDGvVqUTPuXse3Nqc7EAZhmZwehn9QjU7Xhqd4B7l"
    },
    {
      "url": "https://www.facebook.com/share/v/174zepZDpb"
    }
  ],
  "fetch_reaction_map": false,
  "comments_limit": 0,
  "min_wait_time_in_sec": 1,
  "max_wait_time_in_sec": 4,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "post_urls": [
        {
            "url": "https://www.facebook.com/thewitcherfanclub/posts/pfbid02reBdcEgYdgLLP92A7ZJ6KLPcNq3LHha9TjYi2k2ytbeS2q2rxkhCqAWy2m6j3TkRl"
        },
        {
            "url": "https://www.facebook.com/watch/?v=500165819136200"
        },
        {
            "url": "https://www.facebook.com/100063521621753/posts/1128544229272954"
        },
        {
            "url": "https://www.facebook.com/SkyrockFM/videos/nawell-madani-pie%CC%80ge-soprano-/375768715295270/"
        },
        {
            "url": "https://www.facebook.com/reel/1397741784161219"
        },
        {
            "url": "https://www.facebook.com/SpiroSpathisEG/posts/pfbid02J7rXJA5ZmmUPcYvxHDKe1VtVLDGvVqUTPuXse3Nqc7EAZhmZwehn9QjU7Xhqd4B7l"
        },
        {
            "url": "https://www.facebook.com/share/v/174zepZDpb"
        }
    ],
    "fetch_reaction_map": false,
    "comments_limit": 0
};

// Run the Actor and wait for it to finish
const run = await client.actor("alien_force/facebook-posts-comments-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "post_urls": [
        { "url": "https://www.facebook.com/thewitcherfanclub/posts/pfbid02reBdcEgYdgLLP92A7ZJ6KLPcNq3LHha9TjYi2k2ytbeS2q2rxkhCqAWy2m6j3TkRl" },
        { "url": "https://www.facebook.com/watch/?v=500165819136200" },
        { "url": "https://www.facebook.com/100063521621753/posts/1128544229272954" },
        { "url": "https://www.facebook.com/SkyrockFM/videos/nawell-madani-pie%CC%80ge-soprano-/375768715295270/" },
        { "url": "https://www.facebook.com/reel/1397741784161219" },
        { "url": "https://www.facebook.com/SpiroSpathisEG/posts/pfbid02J7rXJA5ZmmUPcYvxHDKe1VtVLDGvVqUTPuXse3Nqc7EAZhmZwehn9QjU7Xhqd4B7l" },
        { "url": "https://www.facebook.com/share/v/174zepZDpb" },
    ],
    "fetch_reaction_map": False,
    "comments_limit": 0,
}

# Run the Actor and wait for it to finish
run = client.actor("alien_force/facebook-posts-comments-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "post_urls": [
    {
      "url": "https://www.facebook.com/thewitcherfanclub/posts/pfbid02reBdcEgYdgLLP92A7ZJ6KLPcNq3LHha9TjYi2k2ytbeS2q2rxkhCqAWy2m6j3TkRl"
    },
    {
      "url": "https://www.facebook.com/watch/?v=500165819136200"
    },
    {
      "url": "https://www.facebook.com/100063521621753/posts/1128544229272954"
    },
    {
      "url": "https://www.facebook.com/SkyrockFM/videos/nawell-madani-pie%CC%80ge-soprano-/375768715295270/"
    },
    {
      "url": "https://www.facebook.com/reel/1397741784161219"
    },
    {
      "url": "https://www.facebook.com/SpiroSpathisEG/posts/pfbid02J7rXJA5ZmmUPcYvxHDKe1VtVLDGvVqUTPuXse3Nqc7EAZhmZwehn9QjU7Xhqd4B7l"
    },
    {
      "url": "https://www.facebook.com/share/v/174zepZDpb"
    }
  ],
  "fetch_reaction_map": false,
  "comments_limit": 0
}' |
apify call alien_force/facebook-posts-comments-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,alien_force/facebook-posts-comments-scraper"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/d6G2Zv1fgn6rhggOa/builds/yGlQFUzt3WcfmxF0x/openapi.json
