# 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
- **Stats:** 774 total users, 30 monthly users, 100.0% runs succeeded, 20 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

$25.00/month + usage

To use this Actor, you pay a monthly rental fee to the developer. The rent is subtracted from your prepaid usage every month after the free trial period.You also pay for the Apify platform usage, which gets cheaper the higher Apify subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#rental-actors

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# 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("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).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": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=alien_force/facebook-posts-comments-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Facebook Posts/Comments Scraper",
        "description": "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.",
        "version": "0.3",
        "x-build-id": "wcHLfd06YvXdMxpsY"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/alien_force~facebook-posts-comments-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-alien_force-facebook-posts-comments-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/alien_force~facebook-posts-comments-scraper/runs": {
            "post": {
                "operationId": "runs-sync-alien_force-facebook-posts-comments-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/alien_force~facebook-posts-comments-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-alien_force-facebook-posts-comments-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "post_urls"
                ],
                "properties": {
                    "post_urls": {
                        "title": "Post Urls",
                        "type": "array",
                        "description": "Add Facebook post urls to scrape posts",
                        "items": {
                            "type": "object",
                            "required": [
                                "url"
                            ],
                            "properties": {
                                "url": {
                                    "type": "string",
                                    "title": "URL of a web page",
                                    "format": "uri"
                                }
                            }
                        }
                    },
                    "fetch_reaction_map": {
                        "title": "Fetch Reaction Map",
                        "type": "boolean",
                        "description": "When turned on, reaction map is fetched for each post of type `video` only. Regular post items are always fetched regardless of this setting.",
                        "default": false
                    },
                    "comments_limit": {
                        "title": "Comments Limit",
                        "type": "integer",
                        "description": "Limit number of comments",
                        "default": 0
                    },
                    "min_wait_time_in_sec": {
                        "title": "Minimum Seconds Awaited",
                        "minimum": 0,
                        "maximum": 2,
                        "type": "integer",
                        "description": "Minimum seconds to wait for each cursor.",
                        "default": 1
                    },
                    "max_wait_time_in_sec": {
                        "title": "Maximum Seconds Awaited",
                        "minimum": 3,
                        "maximum": 6,
                        "type": "integer",
                        "description": "Maximum seconds to wait for each cursor.",
                        "default": 4
                    },
                    "proxyConfiguration": {
                        "title": "Proxy configuration",
                        "type": "object",
                        "description": "Configure proxies to be used by the crawler.",
                        "default": {
                            "useApifyProxy": true
                        }
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
