# Facebook Scraper Pro (`alien_force/facebook-scraper-pro`) Actor

Facebook Scraper Pro is a powerful Apify actor for extracting Facebook data. It includes: Search Scraper (finds posts by keyword), Profiles Scraper (scrapes profile info & posts), Posts Scraper (extracts posts by URL), and Comments Scraper (collects comments from posts). 🚀

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

## Pricing

from $7.00 / 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 Scraper Pro

Facebook Scraper Pro is a powerful Apify actor designed to extract data from Facebook efficiently. It offers multiple scraping functions to gather data from Facebook searches, profiles, posts, and comments. Below is a detailed guide to help you understand and use this actor effectively.

### Key Features

1. **Facebook Search Scraper**: Searches for specific keywords on Facebook and returns relevant posts.
2. **Facebook Profiles Scraper**: Extracts detailed information from Facebook profiles, including ID, name, friends count, likes count, location, gender, profile avatar, birthday, and profile posts.
3. **Facebook Posts Scraper**: Scrapes data from specific Facebook posts, including text, likes, comments, shares, and media.
4. **Facebook Comments Scraper**: Extracts comments from specific Facebook posts, including comment text, likes, replies, and author details.

### Important Notes

- **Actor Function**: Specifies the scraping function to use (facebook_search_scraper, facebook_profiles_scraper, facebook_posts_scraper, facebook_comments_scraper).
- **Rate Limiting**: Use appropriate `min_wait_time_in_sec` and `max_wait_time_in_sec` to avoid blocking.
- **Data Limits**: Use the `results_limit` parameter to control the amount of data scraped.
- **Strict Search**: Use the `strict_search` parameter to only retrieve posts containing the exact keyword provided by `keyword` parameter.
- **Follow Post Scraping**: Use `follow_post_scraping` (default: `true`) to control whether SEARCH and PROFILE results are followed by an additional post-scraping step for more reliable/richer post details.

### Input Schema

The input schema for the Facebook Scraper Pro actor is as follows:

```json
{
    // enum for "function" ["facebook_search_scraper", "facebook_profiles_scraper", "facebook_posts_scraper", "facebook_comments_scraper"]
    "function": "facebook_search_scraper",
    "filter_by_recent_posts": true, // used in facebook_search_scraper
    "since": "1d", // used to fetch data in interval time (1d, 7d, 30d)
    "keyword": "BBC", // used in facebook_search_scraper
    "strict_search": false, // used in facebook_search_scraper

    "results_limit": 5, // limit number of posts or comments returned
    "min_wait_time_in_sec": 2, // minimum seconds to wait for each cursor.
    "max_wait_time_in_sec": 6, // maximum seconds to wait for each cursor.
    "cookies": [], // Optional Facebook user account cookies for improved scraping reliability and maintainability.
    "fetch_reaction_map": false, // When enabled, fetches reaction breakdown for video posts only.
    "follow_post_scraping": true, // When enabled, SEARCH and PROFILE results are followed by post scraping for more reliable post details.

    "profile_urls": [
        // used in facebook_profiles_scraper
        {
            "url": "https://www.facebook.com/profile.php?id=61568555420777"
        }
    ],
    "post_urls": [
        // used in facebook_posts_scraper
        {
            "url": "https://www.facebook.com/watch/?v=918725866988227"
        }
    ],
    "post_urls_for_comments": [
        // used in facebook_comments_scraper
        {
            "url": "https://www.facebook.com/watch/?v=918725866988227"
        }
    ],
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": ["RESIDENTIAL"]
    }
}
```

### Output Schema

#### Facebook Search Scraper, Facebook Profiles Scraper, Facebook Posts Scraper

```json
{
    // "author" only exists in Facebook Profile Scraper Responses
    "author": {
        "user_name": "Chief&amp;Chill",
        "user_id": "61568555420777",
        "user_url": "https://www.facebook.com/profile.php?id=61568555420777",
        "avatar": "https://scontent.fcai20-6.fna.fbcdn.net/v/t39.30808-1/326769796_731573711877409_5775268283301149505_n.jpg?stp=dst-jpg_s200x200_tt6&_nc_cat=1&ccb=1-7&_nc_sid=2d3e12&_nc_ohc=XXAYvfYQ_XgQ7kNvwFiOR3P&_nc_oc=AdneB4lCDPZ95GwkBc18yPBqBDx0KJBbBs3BtpBIarAhHXX_Xe04Bt93nF8-rPbu4mQ&_nc_zt=24&_nc_ht=scontent.fcai20-6.fna&_nc_gid=82BoXRmuCctRCyAwsu2f_w&oh=00_AfJG6Qx8GljgLqvbHK-0LgEBFqp11KvgYfhKtCPYQ84lDw&oe=682E9F53",
        "intro": "Organizing the world's information and making it universally accessible and useful.",
        "email": "for.loop.2020@gmail.com",
        "followers_count": "37K",
        "friends_count": null,
        "likes_count": "750",
        "following_count": null,
        "location": null,
        "gender": "UNKNOWN",
        "birthday": null,
        "created_at": "22 June 2020",
        "category": "Community"
    },
    "post_id": "122118274184618514",
    "action_id": "ZmVlZGJhY2s6MTIyMTE4Mjc0MTg0NjE4NTE0",
    "text": "No Man Sky !!\nCredits @qballgamingYT\n#gamingcommunity\n#gaming\n#besttime\n#funnymoments",
    "create_time": 1737231816,
    "post_url": "https://www.facebook.com/61568555420777/videos/8940928369328022/",
    "like_count": 47,
    "comment_count": 0,
    "share_count": 0,
    "view_count": 0,
    "reaction_map": [
        {
            "name": "Like",
            "count": 3,
            "parsed_count": "3"
        }
    ],
    "play_count": 0,
    "image_list": [
        "https://scontent.fcai20-3.fna.fbcdn.net/v/t39.30808-6/..."
    ],
    "video_list": [],
    "video_cover_image": [
        "https://scontent.fcai20-2.fna.fbcdn.net/v/t15.5256-10/..."
    ],
    "durationInSec": [19.966],
    "type": "video",
    "author_username": "Nabila",
    "author_user_id": "61552615223744",
    "author_profile_url": "https://www.facebook.com/Moviesbaki",
    "author_avatar": "https://scontent.fcai20-3.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"
        }
    ]
}
```

#### Facebook Comments Scraper

```json
{
    "action_id": "ZmVlZGJhY2s6OTAyOTM5NjE2MzgxODE1N185MDI5NDA2MTUzODE3MTU4",
    "comment_id": "9029406153817158",
    "gender": "FEMALE",
    "author_user_id": "100009355176494",
    "author_username": "Lillian Mamdouh",
    "author_profile_url": "https://www.facebook.com/lillian.mamdouh.7",
    "author_avatar": "",
    "text": "Up",
    "like_count": 0,
    "reply_count": 0,
    "create_time": 1738101623,
    "image_list": [],
    "video_list": [],
    "video_cover_image": [],
    "post": {
        "post_id": "9029396163818157",
        "post_url": "https://www.facebook.com/groups/5958702877554183/posts/9029396163818157/",
        "author_user_id": "pfbid036cJegrwq7rXF3Le6BCGDZd8nwuGw31mwx2smn8go2sbjRe23PocViB4H7DW4VgQ6l",
        "author_username": "Perihan Sameh",
        "author_profile_url": null,
        "author_avatar": ""
    },
    "input": "https://www.facebook.com/groups/5958702877554183/posts/9029396163818157/"
}
```

# Actor input Schema

## `cookies` (type: `array`):

1. Install the Cookie-Editor Chrome extension.
2. Log in to your Facebook account.
3. Open the Cookie-Editor extension and export cookies as JSON for facebook.com.
4. Paste the exported cookie contents here.

## `function` (type: `string`):

Select what function to work with this actor.

## `facebook_search_scraper_section` (type: `object`):

No description

## `keyword` (type: `string`):

Provide a keyword to search in Facebook posts.

## `strict_search` (type: `boolean`):

When enabled, only posts containing the exact keyword provided will be included.

## `filter_by_recent_posts` (type: `boolean`):

When selected, newer posts will be fetched first.

## `since` (type: `string`):

Filter by time interval. only works with `facebook_search_scraper` and will override the `filter_by_recent_posts` filter

## `facebook_profiles_scraper_section` (type: `object`):

No description

## `profile_urls` (type: `array`):

Add Facebook profile urls to scrape posts

## `facebook_posts_scraper` (type: `object`):

No description

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

Add Facebook post urls to scrape posts

## `facebook_comments_scraper` (type: `object`):

No description

## `post_urls_for_comments` (type: `array`):

Add Facebook post urls to scrape posts comments

## `extra` (type: `object`):

No description

## `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.

## `follow_post_scraping` (type: `boolean`):

When turned on, SEARCH and PROFILE posts scraping will be followed by post scraping for reliable results.

## `options` (type: `object`):

No description

## `results_limit` (type: `integer`):

Limit number of results, minimum is 10 results

## `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.

## `proxy_configuration_section` (type: `object`):

No description

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

Configure proxies to be used by the crawler. Facebook blocks search from datacenter IPs, so keep the Residential proxy group selected.

## Actor input object example

```json
{
  "cookies": [],
  "function": "facebook_search_scraper",
  "keyword": "BBC",
  "strict_search": false,
  "filter_by_recent_posts": false,
  "since": "all_times",
  "profile_urls": [],
  "post_urls": [],
  "post_urls_for_comments": [],
  "fetch_reaction_map": false,
  "follow_post_scraping": true,
  "results_limit": 10,
  "min_wait_time_in_sec": 1,
  "max_wait_time_in_sec": 4,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# 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 = {
    "cookies": [],
    "function": "facebook_search_scraper",
    "keyword": "BBC",
    "strict_search": false,
    "filter_by_recent_posts": false,
    "fetch_reaction_map": false,
    "follow_post_scraping": true,
    "results_limit": 10,
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("alien_force/facebook-scraper-pro").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 = {
    "cookies": [],
    "function": "facebook_search_scraper",
    "keyword": "BBC",
    "strict_search": False,
    "filter_by_recent_posts": False,
    "fetch_reaction_map": False,
    "follow_post_scraping": True,
    "results_limit": 10,
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
    },
}

# Run the Actor and wait for it to finish
run = client.actor("alien_force/facebook-scraper-pro").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 '{
  "cookies": [],
  "function": "facebook_search_scraper",
  "keyword": "BBC",
  "strict_search": false,
  "filter_by_recent_posts": false,
  "fetch_reaction_map": false,
  "follow_post_scraping": true,
  "results_limit": 10,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}' |
apify call alien_force/facebook-scraper-pro --silent --output-dataset

```

## MCP server setup

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

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/Lnz4QRVI89bcQAUGQ/builds/cCfaqLaHAg5Ce0SXO/openapi.json
