# Facebook Posts Scraper (`datapilot/facebook-posts-scraper`) Actor

Just provide the page URL. The page name, post ID, link, text, likes, comments, shares — all data will be collected and stored directly in your Apify dataset.

Works with residential proxies for reliable data extraction.

Fast and easy — optimized for scraping public page data from Facebook.

- **URL**: https://apify.com/datapilot/facebook-posts-scraper.md
- **Developed by:** [Data Pilot](https://apify.com/datapilot) (community)
- **Categories:** Other, Social media
- **Stats:** 20 total users, 3 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$10.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 Posts Scraper

🚀 **Facebook Posts Scraper** is a powerful Apify Actor designed to extract public post data from **Facebook** pages without using the official Facebook API. It leverages **residential proxies** to avoid IP blocks and delivers clean, structured data – perfect for **social media monitoring**, market research, competitor analysis, and content strategy.


### 🔥 Features

- **No Official API Required** – scrapes public **Facebook post data** directly, serving as a true **Facebook API alternative**.
- **Smart Proxy Integration** – uses **Apify residential proxies** to avoid IP blocks and achieve **Facebook rate limit bypass**, ensuring reliable **Facebook data extraction**.
- **Batch Processing** – accepts multiple **Facebook page URLs** (or post URLs) in a single run.
- **Comprehensive Post Metadata** – extracts **post ID**, **post text**, **like count**, **comment count**, **share count**, **page name**, **URL**, and **scraped timestamp**.
- **Sample Data Generation** – (for demo purposes) generates realistic sample posts; easily replace with real scraping logic using tools like `facebook-scraper` or `Playwright`.
- **Apify Dataset Ready** – each post's metadata is pushed as a separate dataset item for easy export (JSON, CSV, XML).
- **Async Architecture** – fast, non‑blocking **async Python scraper** built with asyncio.
- **Lightweight & Extensible** – easily customisable to add more fields or integrate with headless browsers for JavaScript‑rendered content.

---

### ⚙️ How It Works

1. **Input** – Provide one or more **Facebook page URLs** (or post URLs) as input. The Actor also accepts a single URL if you prefer.
2. **Proxy** – Actor initialises a **residential proxy** via Apify Proxy (recommended for **Facebook anti-block**).
3. **Scrape** – For each URL, the Actor generates sample post data (or you can replace the logic with real scraping using libraries like `facebook-scraper` or `Playwright`). The current implementation demonstrates the data structure and proxy integration.
4. **Output** – Each post's data is pushed to the Apify Dataset – a perfect **Facebook data export** solution.
5. **Finish** – Logs total scraped posts and exits.

---

### 📥 Input

The Actor accepts a JSON input with the following fields:

| Field                 | Type            | Default                                   | Description |
|-----------------------|-----------------|-------------------------------------------|-------------|
| `facebookUrls`        | string / array  | **required**                              | One or more **Facebook page URLs** (e.g., `"https://www.facebook.com/example"`). The Actor also accepts `facebookUrl` or `url` for backward compatibility. |
| `proxyConfiguration`  | object          | `{"useApifyProxy": true, "apifyProxyGroups": ["RESIDENTIAL"]}` | Proxy settings – **Facebook residential proxy** recommended. |

**Example input:**

```json
{
  "facebookUrls": [
    "https://www.facebook.com/examplepage",
    "https://www.facebook.com/anotherpage"
  ],
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": ["RESIDENTIAL"]
  }
}
````

***

### 📤 Output

Each dataset item corresponds to one Facebook post:

| Field           | Type   | Description |
|-----------------|--------|-------------|
| `facebookUrl`   | string | The original Facebook page URL. |
| `postId`        | string | Unique identifier of the post. |
| `pageName`      | string | Name of the Facebook page. |
| `url`           | string | Direct URL to the post. |
| `scrapedAt`     | string | ISO timestamp of when the data was scraped. |
| `text`          | string | The post's text content. |
| `likes`         | int    | Number of likes on the post – Facebook like count. |
| `comments`      | int    | Number of comments on the post – Facebook comment count. |
| `shares`        | int    | Number of shares – Facebook share count. |

**Example output item:**

```json
{
  "facebookUrl": "https://www.facebook.com/examplepage",
  "postId": "1234567890123456",
  "pageName": "examplepage",
  "url": "https://www.facebook.com/examplepage/posts/1234567890123456",
  "scrapedAt": "2025-02-14T12:34:56Z",
  "text": "Sample post content #1 from examplepage",
  "likes": 567,
  "comments": 42,
  "shares": 18
}
```

***

### 🧰 Technical Stack

- **Language:** Python 3.11+ (async/await)
- **Core Scraper:** \`facebook-scraper\`\` – flexible integration for Facebook data extraction.
- **Proxy:** Apify Proxy with RESIDENTIAL group – real peer IPs, high anonymity.
- **Platform:** Apify Actor – serverless, scalable, integrated with Dataset and Key‑Value Store.
- **Deployment:** One‑click run on Apify Console or via REST API.

***

### 🎯 Use Cases

- **Social Media Monitoring** – track brand mentions and competitor activity on Facebook.
- **Market Research** – analyse public sentiment and engagement on Facebook pages.
- **Competitor Analysis** – monitor competitor posts, engagement, and content strategies.
- **Content Strategy** – identify trending topics and successful post formats on Facebook.
- **Brand Reputation** – track public feedback and comments about your brand.
- **Influencer Marketing** – analyse influencer page performance and engagement metrics.
- **Academic Research** – collect Facebook data for social science studies.
- **Social Media Dashboard** – integrate Facebook data into analytics platforms.
- **Crisis Management** – monitor public reactions during brand emergencies.
- **Lead Generation** – identify potential customers through Facebook page interactions.
- **Social Listening** – gather insights on customer opinions and preferences.

***

### 🚀 Quick Start

1. **Open in Apify Console** – visit the Actor page and click Try for free.
2. **Paste Facebook URL(s)** in the input field (one URL or multiple URLs).
3. **Enable residential proxies** (recommended for reliable access).
4. **Click Start** and wait for results.
5. **Export** – download post metadata as JSON, CSV, HTML, or Excel.

You can also call this Actor programmatically via Apify SDK or REST API – ideal for automated pipelines.

***

### 💎 Why Use This Actor?

| Feature | Benefit |
|---------|---------|
| ✅ No Facebook API quotas | Extract unlimited post data without API rate limits. |
| ✅ Residential proxies | Bypass Facebook anti-bot detection – high success rate. |
| ✅ Batch processing | Scrape multiple pages in one run. |
| ✅ Complete metadata | Get post stats, engagement metrics, text content, and timestamps. |
| ✅ Clean schema | Ready for immediate analysis or database ingestion. |
| ✅ Apify ecosystem | Seamless integration with other Actors, triggers, and webhooks. |
| ✅ No authentication | Works with public Facebook content – no login required. |
| ✅ Extensible | Easily customise to add more fields or integrate advanced tools. |

***

### ⚠️ Important Notes

- **Facebook Terms of Service** – Use responsibly and at reasonable speed. This Actor is meant for personal, educational, or research use on public data only.
- **Proxy Credits** – Residential proxy usage consumes Apify platform credits. Free tier may have limited availability.
- **Rate Limiting** – Facebook aggressively rate limits scrapers. Use reasonable intervals between requests and consider distributed scraping.
- **Public Data Only** – Only scrape publicly available posts and pages. Respect user privacy and Facebook's policies.
- **Dynamic Content** – Facebook heavily relies on JavaScript rendering. For best results, consider integrating with Playwright or Puppeteer for JavaScript-rendered content.
- **Library Updates** – If Facebook changes its structure, the underlying scraping library may need updates. We monitor and maintain regularly.

### 📦 Changelog

#### v1.0.0 (February 2025)

- Initial release with residential proxy support.
- Batch processing for multiple Facebook page URLs.
- Extracts comprehensive post metadata (text, engagement metrics, timestamps).
- Sample data generation for demo purposes.
- Easily extensible for real scraping integration.
- Full Apify Actor integration.

***

### 🧑‍💻 Support & Feedback

- **Issues & Ideas:** Open a ticket on the Apify Actor issue tracker.
- **Contributions:** Pull requests are welcome via the GitHub repository.
- **Documentation:** Visit Apify Docs for platform guides.
- **Community:** Join the Apify community forum for discussions and support.

***

### 📄 License

This Actor is provided as-is for educational, research, and personal use. Ensure compliance with Facebook's Terms of Service and applicable laws when scraping.

# Actor input Schema

## `facebookUrls` (type: `string`):

Paste one URL per line (Example: https://www.facebook.com/facebook OR https://www.facebook.com/Meta)

## `useResidentialProxy` (type: `boolean`):

Enable Residential Proxy (Default: ON)

## `proxyCountry` (type: `string`):

Select country

## Actor input object example

```json
{
  "facebookUrls": "https://www.facebook.com/facebook\nhttps://www.facebook.com/Meta",
  "useResidentialProxy": true,
  "proxyCountry": "US"
}
```

# 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 = {
    "facebookUrls": `https://www.facebook.com/facebook
https://www.facebook.com/Meta`
};

// Run the Actor and wait for it to finish
const run = await client.actor("datapilot/facebook-posts-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 = { "facebookUrls": """https://www.facebook.com/facebook
https://www.facebook.com/Meta""" }

# Run the Actor and wait for it to finish
run = client.actor("datapilot/facebook-posts-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 '{
  "facebookUrls": "https://www.facebook.com/facebook\\nhttps://www.facebook.com/Meta"
}' |
apify call datapilot/facebook-posts-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=datapilot/facebook-posts-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Facebook Posts Scraper",
        "description": "Just provide the page URL. The page name, post ID, link, text, likes, comments, shares — all data will be collected and stored directly in your Apify dataset.\n\nWorks with residential proxies for reliable data extraction.\n\nFast and easy — optimized for scraping public page data from Facebook.",
        "version": "0.0",
        "x-build-id": "cedhcn1ow2eAo1CAC"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/datapilot~facebook-posts-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-datapilot-facebook-posts-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/datapilot~facebook-posts-scraper/runs": {
            "post": {
                "operationId": "runs-sync-datapilot-facebook-posts-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/datapilot~facebook-posts-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-datapilot-facebook-posts-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": [
                    "facebookUrls"
                ],
                "properties": {
                    "facebookUrls": {
                        "title": "Facebook URLs",
                        "type": "string",
                        "description": "Paste one URL per line (Example: https://www.facebook.com/facebook OR https://www.facebook.com/Meta)"
                    },
                    "useResidentialProxy": {
                        "title": "Use Residential Proxy",
                        "type": "boolean",
                        "description": "Enable Residential Proxy (Default: ON)",
                        "default": true
                    },
                    "proxyCountry": {
                        "title": "Proxy Country",
                        "enum": [
                            "US",
                            "GB",
                            "DE",
                            "FR",
                            "CA",
                            "AU"
                        ],
                        "type": "string",
                        "description": "Select country",
                        "default": "US"
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
