# Facebook Posts Search Scraper (`easyapi/facebook-posts-search-scraper`) Actor

Effortlessly extract posts from Facebook search results. This actor automates the collection of posts based on custom queries, providing detailed information such as post content, engagement metrics, and author details. Ideal for social media monitoring, market research, and trend analysis.

- **URL**: https://apify.com/easyapi/facebook-posts-search-scraper.md
- **Developed by:** [EasyApi](https://apify.com/easyapi) (community)
- **Categories:** Social media
- **Features:** Limited permissions
- **Stats:** 1,470 total users, 26 monthly users, 100.0% runs succeeded, 29 bookmarks
- **User rating**: 4.33 out of 5 stars

## Pricing

from $2.99 / 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.

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 Posts Search Scraper

Effortlessly extract posts from Facebook search results based on your query.

### Features

- 🔍 Scrape posts from Facebook search results using custom queries
- 📊 Extract detailed information about each post, including likes, comments, and shares
- 🔢 Set a custom limit for the number of posts to scrape
- 🚀 Uses browser automation to handle dynamic content
- 🛡️ Incorporates anti-detection measures for reliable scraping

### Description

The Facebook Posts Search Scraper is a powerful tool designed to automate the process of extracting posts from Facebook search results. It navigates through the search results page, scrolling and loading more content as needed, to collect comprehensive information about each post matching your search criteria.

### Input Parameters

| Field | Type | Description |
| --- | --- | --- |
| `searchQuery` | String | The search query to find Facebook posts |
| `maxPosts` | Integer | Maximum number of posts to scrape (default: 100, max: 5000) |

### Output

The actor provides detailed information for each post, including:

- `facebookUrl`: URL of the Facebook page that made the post
- `pageId`: Unique identifier of the Facebook page
- `postId`: Unique identifier of the post
- `pageName`: Name of the Facebook page
- `url`: Direct URL to the post
- `time`: Formatted date and time of the post
- `timestamp`: Unix timestamp of the post
- `likes`: Number of likes on the post
- `comments`: Number of comments on the post
- `shares`: Number of times the post has been shared
- `text`: The actual content of the post
- `link`: URL of any link attached to the post
- `thumb`: URL of the thumbnail image (if available)
- `topLevelUrl`: Constructe

### Use Cases

- Social media monitoring: Track mentions of specific keywords or phrases
- Competitive analysis: Research posts related to competitors or industry trends
- Market research: Gather insights on public discussions about products or services
- Content curation: Find relevant posts for content marketing or reporting
- Trend analysis: Identify popular topics and discussions within specific search queries

Gain valuable insights from Facebook post search results with the Facebook Posts Search Scraper!

#### Input Example

A full explanation of an input example in JSON.

```
{
  "maxItems": 10,
  "searchQuery": "football"
}
```

#### Output sample

The results will be wrapped into a dataset which you can always find in the **Storage** tab. Here's an excerpt from the data you'd get if you apply the input parameters above:

And here is the same data but in JSON. You can choose in which format to download your data: JSON, JSONL, Excel spreadsheet, HTML table, CSV, or XML.

```
[
{
	"facebookUrl": "https://www.facebook.com/BleacherReportFootball",
	"pageId": "100044187438640",
	"postId": "1150692399746997",
	"pageName": "Bleacher Report Football",
	"url": "https://www.facebook.com/BleacherReportFootball/posts/pfbid02KPDjc6DpFw1KDQYwptdvvUwGF4GLjsQZnfyU8g3osUAzonhcr2crgEJTKSroqWt6l",
	"time": "2024-10-01 18:11:20",
	"timestamp": 1727777480,
	"likes": 18189,
	"comments": 399,
	"shares": "2.4K",
	"text": "After 1,016 games and 38 trophies, 40-year-old Andrés Iniesta is finally hanging up his boots. One of the greatest to ever do it ✨🇪🇸",
	"link": "https://www.facebook.com/photo/?fbid=1150688623080708&set=a.274973270652252",
	"thumb": "https://scontent-ams4-1.xx.fbcdn.net/v/t39.30808-6/461867291_1150688626414041_3301490527386528216_n.jpg?_nc_cat=107&ccb=1-7&_nc_sid=127cfc&_nc_ohc=AiHZSsVt6KEQ7kNvgEYueNX&_nc_ht=scontent-ams4-1.xx&_nc_gid=AciHdLzF0Usp66QNMP-zbbm&oh=00_AYDH8qoqGJfpzhYvHPwvO5i1Vx3kSYm5NHuCkc7uac0SGA&oe=670BAE6B",
	"topLevelUrl": "https://www.facebook.com/100044187438640/posts/1150692399746997",
	"facebookId": "100044187438640",
	"postFacebookId": "1150692399746997"
},
{
	"facebookUrl": "https://www.facebook.com/BleacherReportFootball",
	"pageId": "100044187438640",
	"postId": "1155050565977847",
	"pageName": "Bleacher Report Football",
	"url": "https://www.facebook.com/BleacherReportFootball/posts/pfbid0WbTYHzp7Cg8CkXLgTAbDmZQy7XvzF1v2bRSM2aTDC394LSqWTvuw6ggtaYaCu9EMl",
	"time": "2024-10-07 20:08:01",
	"timestamp": 1728302881,
	"likes": 16896,
	"comments": 1071,
	"shares": "1.9K",
	"text": "𝟏𝟎/𝟕. It's GOAT day 🐐",
	"link": "https://www.facebook.com/photo/?fbid=1155050412644529&set=a.274973270652252",
	"thumb": "https://scontent-ams4-1.xx.fbcdn.net/v/t39.30808-6/462272513_1155050419311195_494466168420217208_n.jpg?_nc_cat=101&ccb=1-7&_nc_sid=127cfc&_nc_ohc=9sKAaIQLBTkQ7kNvgGG5Nud&_nc_ht=scontent-ams4-1.xx&_nc_gid=AciHdLzF0Usp66QNMP-zbbm&oh=00_AYAZnl6PWZ99war6Y2i2gom6gAskQXoh3GK7swFR59phPw&oe=670BD8A9",
	"topLevelUrl": "https://www.facebook.com/100044187438640/posts/1155050565977847",
	"facebookId": "100044187438640",
	"postFacebookId": "1155050565977847"
},
  ...
]
```

# Actor input Schema

## `searchQuery` (type: `string`):

The search query to find Facebook posts. Choose either this or Search URL.

## `searchUrl` (type: `string`):

Complete Facebook search results page URL. Choose either this or Search Query.

## `maxPosts` (type: `integer`):

The maximum number of posts to scrape from the search results. The actor will stop when this limit is reached.

## `postTimeRange` (type: `string`):

Filter posts by time range

## Actor input object example

```json
{
  "searchQuery": "football",
  "maxPosts": 10
}
```

# 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 = {
    "searchQuery": "football"
};

// Run the Actor and wait for it to finish
const run = await client.actor("easyapi/facebook-posts-search-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 = { "searchQuery": "football" }

# Run the Actor and wait for it to finish
run = client.actor("easyapi/facebook-posts-search-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 '{
  "searchQuery": "football"
}' |
apify call easyapi/facebook-posts-search-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,easyapi/facebook-posts-search-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/4YfcIWyRtJHJ5Ha3a/builds/Z0gcQhQGblIns3Dr2/openapi.json
