# Facebook 公开评论抓取器 (`spbotdel/facebook-comments-cn`) Actor

抓取 Facebook 公开帖子评论和回复线程，无需登录或 Cookie。导出文本、作者、时间、互动、评论链接和线程关系，支持 API、MCP、定时任务和 JSON、CSV、Excel。

- **URL**: https://apify.com/spbotdel/facebook-comments-cn.md
- **Developed by:** [Sergei Belostotskii](https://apify.com/spbotdel) (community)
- **Categories:** Social media, MCP servers, Automation
- **Stats:** 1 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.20 / 1,000 评论

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

**无需登录、无需 Cookie、也无需浏览器，即可抓取 Facebook 公开帖子评论和完整回复线程。**

Facebook 公开评论抓取器会把 Facebook 帖子链接转换为结构化数据集，每条评论或回复占一行。Actor 会沿 Facebook 的真实分页游标遍历评论，展开回复线程，保留父子关系，并在运行摘要中报告公开内容覆盖率。

适用于舆情监听、竞品分析、品牌监测、社群研究、线索整理、内容审核和 AI 数据管道。结果可通过 Apify API、MCP Server、定时任务、Webhook，以及 JSON、CSV、Excel 等格式导出。

可以先运行现成示例：[评论线程演示](https://apify.com/spbotdel/facebook-comments-cn/examples/facebook-comment-thread-demo-cn)。

### 可以抓取哪些数据

- 评论和回复原文。
- 公开作者名称、作者 ID、主页链接和头像。
- ISO 时间戳和 Unix 时间。
- 评论总互动数，以及可用的分类互动数据。
- 回复数量、父评论 ID、嵌套深度和稳定评论链接。
- 来源帖子链接、帖子 ID、可选帖子正文和评论中的 HTTP 链接。
- 每个帖子的覆盖摘要：Facebook 显示数量、实际抓取数量、覆盖率、停止原因和是否被登录墙限制。

每条公开评论或回复都会写入一行数据集。回复通过 `parent_comment_id` 和 `depth` 关联，方便还原对话结构。

### 为什么使用这个 Actor

#### 不需要 Facebook 登录

Actor 只访问未登录访客可以看到的公开页面。无需提供 Facebook 账号、Cookie 或浏览器会话，也不存在账号被限制的风险。

#### 真实的游标分页

Facebook 通常每页返回 10 条评论。Actor 会持续跟踪 `end_cursor`，直到 Facebook 不再提供下一页。实测可从公开帖子抓取 400 条不同评论，共 40 页。

#### 回复线程也会继续分页

对于公开可访问的内容，Actor 会展开回复线程并继续翻页，包括二级回复。实测在 9 次请求中抓取了 83 条回复中的 81 条。

#### 支持批量与定时监控

单次运行最多处理 100 个帖子链接，并可同时处理 1 到 20 个帖子。每个帖子维护独立的分页游标和请求间隔。

定时任务可以使用 `dedupeStoreName`、`knownCommentIds` 或 `knownDatasetId`，只返回上次运行后出现的新评论。

#### 公开数据边界有明确说明

Facebook 显示的评论总数可能包含仅登录用户可见、被过滤、已删除或隐私受限的内容。Actor 不会把公开抓取数量伪装成完整总量，而是通过 `announcedComments`、`coveragePercent`、`blocked` 和 `stopReason` 说明真实覆盖情况。

#### 代理自动回退

`proxyTier: "auto"` 会先使用成本更低的数据中心代理；如果 Facebook 拦截请求，再自动切换到住宅代理。也可以强制使用 `datacenter` 或 `residential`。

### 支持的 Facebook 页面

| 页面类型 | 未登录是否支持 | 说明 |
|---|---|---|
| 公共主页帖子：`/posts/pfbid...` | 支持 | 可通过游标抓取公开评论和回复。 |
| 小组帖子：`/groups/.../permalink/...` | 受 Facebook 限制 | 未登录访客通常只能看到部分评论和少量回复。 |
| 旧版帖子：`story.php?story_fbid=...` | 支持 | 会先转换为标准帖子链接。 |
| 视频页面：`/videos/...` | 支持 | 仅限 Facebook 向未登录访客公开评论列表的视频。 |
| Reels：`/reel/...` | 不支持未登录抓取 | 页面可能显示评论数，但不会向未登录访客返回评论列表。 |
| 照片：`/photo?fbid=...` | 不支持未登录抓取 | 与 Reels 相同。 |
| Watch：`/watch/?v=...` | 不支持未登录抓取 | 建议改用支持的帖子或视频永久链接。 |

不支持的页面也会被识别，并在运行摘要中标记 `blocked`，不会伪装成成功的空结果。

#### 为什么抓取数量可能少于 Facebook 显示数量

帖子上的计数包含所有评论和回复，包括未登录访客不可见、隐私受限、被过滤或已被删除的内容。无 Cookie 抓取器只能获取公开可见部分。Facebook 官方评论抓取器也说明了相同限制，这不是解析错误或代理故障。

要提高公开覆盖率，建议保持 `includeReplies: true` 和 `unionSorts: true`。在一条显示 168 条评论的帖子中，启用回复和双排序窗口后，公开结果从 94 条增加到 129 条。

### 快速开始

#### 单帖子抓取

```json
{
  "postUrls": [
    "https://www.facebook.com/humansofnewyork/posts/pfbid0BbKbkisExKGSKuhee9a7i86RwRuMKFC8NSkKStB7CsM3uXJuAAfZLrkcJMXxhH4Yl"
  ],
  "maxCommentsPerPost": 100
}
```

#### 批量帖子与回复

```json
{
  "postUrls": [
    "https://www.facebook.com/page/posts/123",
    "https://www.facebook.com/groups/123/permalink/456/"
  ],
  "maxPostsPerRun": 20,
  "maxConcurrency": 5,
  "maxCommentsPerPost": 500,
  "includeReplies": true,
  "maxReplyThreadsPerPost": 50,
  "maxRepliesPerPost": 300,
  "unionSorts": true,
  "pageDelayMs": 1000
}
```

#### 定时只抓新评论

```json
{
  "postUrls": [
    "https://www.facebook.com/page/posts/123"
  ],
  "commentsSortOrder": "NEWEST",
  "dedupeStoreName": "facebook-comment-monitor-cn",
  "onlyCommentsNewerThan": "7 days",
  "failOnEmpty": true
}
```

第一次运行会把已交付评论 ID 写入指定的 Key-Value Store。之后使用相同名称运行时，只返回尚未交付的新评论。

### 输入字段

| 字段 | 类型 | 默认值 | 说明 |
|---|---|---:|---|
| `postUrls` | array | 必填 | Facebook 公开帖子、标题页帖子、视频、`pfbid` 或 `story.php` 链接。 |
| `maxCommentsPerPost` | integer | 300 | 每个帖子的评论与回复总上限，最高 1000。 |
| `maxPostsPerRun` | integer | 5 | 单次运行最多处理的帖子数，最高 100。 |
| `maxConcurrency` | integer | 5 | 并行处理帖子数，范围 1 到 20。 |
| `commentsSortOrder` | enum | `MOST_RELEVANT` | `MOST_RELEVANT`、`NEWEST` 或 `ALL_COMMENTS`。 |
| `unionSorts` | boolean | true | 同时遍历默认排序和最新排序，并合并去重。 |
| `includeReplies` | boolean | true | 展开回复线程。 |
| `maxReplyThreadsPerPost` | integer | 20 | 每个帖子展开的回复线程数。 |
| `maxRepliesPerPost` | integer | 200 | 每个帖子的回复行数上限。 |
| `onlyCommentsNewerThan` | string | 关闭 | 支持 `2026-04-20`、`30 days`、`12 hours`、`2 weeks`。 |
| `pageDelayMs` | integer | 1000 | 分页间隔，建议从 1000 毫秒开始；200 到 400 毫秒也已测试。 |
| `maxPagesPerPost` | integer | 60 | 每个帖子的安全分页上限。 |
| `introDelayMs` | integer | 1500 | 打开帖子页面后的等待时间。 |
| `knownCommentIds` | array | 关闭 | 需要跳过的评论 ID。 |
| `knownDatasetId` | string | 关闭 | 需要读取历史评论 ID 的数据集。 |
| `dedupeStoreName` | string | 关闭 | 跨运行保存已交付评论 ID 的 Key-Value Store 名称。 |
| `failOnEmpty` | boolean | false | 没有抓取到评论时是否将运行标记为失败。 |
| `includePostText` | boolean | false | 是否在每行结果中加入帖子正文 `post_text`。 |
| `proxyTier` | enum | `auto` | `auto`、`datacenter` 或 `residential`。 |
| `proxyCountry` | string | `US` | 住宅代理国家代码。 |
| `startCursorByPost` | object | `{}` | 可选，从上次运行摘要中的游标继续。 |

### 输出字段

| 字段 | 说明 |
|---|---|
| `source_post_url`、`source_post_id`、`input_url` | 来源帖子信息。 |
| `source_comment_id`、`raw_id`、`decoded_id` | 评论标识。 |
| `parent_comment_id`、`depth` | 回复关系与嵌套深度。 |
| `author_id`、`author_name`、`author_url`、`author_picture` | 公开作者信息。 |
| `raw_text` | 评论原文。 |
| `extracted_urls` | 评论中的 HTTP 或 HTTPS 链接。 |
| `created_time`、`created_at` | Unix 时间与 ISO 时间。 |
| `reactions`、`likes` | 总互动数。 |
| `reactions_breakdown` | like、love、haha、wow、sad、angry、care 分类统计。 |
| `reply_count`、`comments_count` | 回复与对话数量。 |
| `comment_url` | 稳定的评论永久链接。 |
| `post_text` | 启用 `includePostText` 后加入的帖子正文。 |

### 运行摘要

默认 Key-Value Store 中的 `OUTPUT` 记录包含：

- `announcedComments`：Facebook 显示的评论数量。
- `rowsPushed`：实际写入数据集的评论和回复数量。
- `coveragePercent`：公开内容覆盖率。
- `blocked`：例如 `comment_list_not_served_without_login`。
- `stopReason`：分页完成、达到上限、日期过滤、页面限制或安全停止。

摘要记录不计入默认数据集费用。

### 定价

| 事件 | FREE | BRONZE 及以上 |
|---|---:|---:|
| Actor 启动 | $0.003 | $0.003 |
| 每条评论或回复 | $0.003 | $0.0012 |

BRONZE 及以上每 1000 条评论为 **$1.20**；FREE 套餐为 **$3.00**。平台计算和代理由 Apify 按用户账单单独计费。

### API、MCP 和 AI 代理

Actor ID：

```text
spbotdel/facebook-comments-cn
```

```bash
curl -X POST \
  "https://api.apify.com/v2/acts/spbotdel~facebook-comments-cn/runs?token=<APIFY_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"postUrls":["https://www.facebook.com/example/posts/123"],"maxCommentsPerPost":100}'
```

在 MCP 客户端中加入：

```json
{
  "mcpServers": {
    "apify": {
      "url": "https://mcp.apify.com"
    }
  }
}
```

AI 代理可以先用 `search-actors` 发现 Actor，再用 `fetch-actor-details` 读取输入、输出和 README，通过 `call-actor` 启动运行，并用 `get-dataset-items` 获取数据。

### 示例任务

- [评论线程演示](https://apify.com/spbotdel/facebook-comments-cn/examples/facebook-comment-thread-demo-cn)
- [抓取评论回复和互动](https://apify.com/spbotdel/facebook-comments-cn/examples/facebook-replies-reactions-cn)
- [监控 Facebook 新评论](https://apify.com/spbotdel/facebook-comments-cn/examples/facebook-comment-monitor-cn)
- [分析竞争对手评论](https://apify.com/spbotdel/facebook-comments-cn/examples/facebook-competitor-comments-cn)
- [抓取 Facebook 小组评论](https://apify.com/spbotdel/facebook-comments-cn/examples/facebook-group-comments-cn)
- [导出 Facebook 评论到 CSV](https://apify.com/spbotdel/facebook-comments-cn/examples/facebook-comments-csv-cn)
- [监控品牌评论](https://apify.com/spbotdel/facebook-comments-cn/examples/facebook-brand-comment-monitor-cn)
- [生成 AI 可用评论数据集](https://apify.com/spbotdel/facebook-comments-cn/examples/facebook-ai-comment-dataset-cn)

### 常见问题

#### 需要 Facebook Cookie 或登录吗？

不需要。Actor 只抓取未登录访客可以访问的公开内容。

#### 为什么抓取数量少于帖子显示数量？

Facebook 的计数包含未登录不可见、隐私受限、被过滤、已删除的评论和回复。Actor 会报告公开覆盖率，而不是把不完整结果伪装成完整数据。

#### 可以抓取私密小组吗？

不可以。私密小组、好友可见内容和登录墙后的内容不在支持范围内。

#### 支持 Reels、照片和 Watch 吗？

这些页面会被识别，但 Facebook 不向未登录访客提供评论列表。运行摘要会标记为 `blocked`。

#### 如何最大限度提高评论覆盖率？

保持 `includeReplies: true` 和 `unionSorts: true`，提高回复线程上限，并避免把 `maxCommentsPerPost` 设置得过低。

#### 可以只抓新评论吗？

可以。使用稳定的 `dedupeStoreName`，并可同时设置 `knownCommentIds`、`knownDatasetId` 或 `onlyCommentsNewerThan`。

### 支持与声明

这是独立的 Facebook 评论抓取器，与 Meta Platforms 或 Facebook 没有隶属、授权或赞助关系。请仅处理公开数据，并遵守 Facebook 条款及适用法律。

# Changelog

This Actor's version history is a separate document: https://apify.com/spbotdel/facebook-comments-cn/changelog.md

# Actor input Schema

## `postUrls` (type: `array`):

Facebook 公开链接。未登录支持：公共主页帖子、小组永久链接、story.php 和视频页面。Reels、照片页面和 /watch/ 会被识别，但 Facebook 不向未登录访客提供评论列表。

## `maxCommentsPerPost` (type: `integer`):

每个帖子写入的评论和回复总上限。公开帖子每页约 10 条，最高 1000。

## `maxPostsPerRun` (type: `integer`):

单次运行最多处理的帖子链接数量，最高 100。

## `maxConcurrency` (type: `integer`):

同时处理的帖子数量。每个帖子维护独立游标和请求间隔。

## `queryMode` (type: `string`):

FRESH_LIST 使用实时评论分页查询，推荐使用。LEGACY_TOPLEVEL 是旧分页器，可能重复返回同一批评论。

## `unionSorts` (type: `boolean`):

同时遍历默认排序和最新排序，并合并不同评论 ID。可以提高公开内容覆盖率。

## `commentsSortOrder` (type: `string`):

Facebook 评论排序方式。MOST_RELEVANT 使用默认相关度，NEWEST 使用倒序时间，ALL_COMMENTS 使用未过滤时间排序。

## `knownCommentIds` (type: `array`):

已经拥有的评论 ID，运行时会跳过，适合增量监控。

## `knownDatasetId` (type: `string`):

包含历史评论 ID 的数据集 ID。需要 Actor 有读取该数据集的权限。

## `dedupeStoreName` (type: `string`):

跨运行保存已交付评论 ID 的 Key-Value Store 名称。使用固定名称时，重复运行只返回新评论。

## `failOnEmpty` (type: `boolean`):

没有抓取到评论时将运行标记为失败，适合定时监控。

## `includePostText` (type: `boolean`):

把帖子正文复制到每行结果的 `post_text` 字段，不增加额外请求。

## `includeReplies` (type: `boolean`):

展开顶层评论下的回复线程，并继续分页到公开可见的末尾。

## `maxReplyThreadsPerPost` (type: `integer`):

展开多少个有回复的顶层评论，优先处理回复最多的线程。0 表示关闭。

## `maxRepliesPerPost` (type: `integer`):

每个帖子写入的回复行数上限，同时计入 `maxCommentsPerPost`。

## `pageDelayMs` (type: `integer`):

GraphQL 分页之间的等待时间。默认 1000 毫秒最稳妥，200 到 400 毫秒也经过测试。

## `maxPagesPerPost` (type: `integer`):

分页安全上限。按每页约 10 条评论计算，60 页约为 600 条。

## `introDelayMs` (type: `integer`):

首次 GraphQL 请求前等待页面稳定，0 表示关闭。

## `onlyCommentsNewerThan` (type: `string`):

只保留该时间之后的评论。支持绝对日期或 `30 days`、`12 hours`、`2 weeks` 等相对时间。

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

住宅代理使用的两位国家代码。已验证运行使用 US。

## `proxyTier` (type: `string`):

auto 先使用成本更低的数据中心代理，被 Facebook 拦截后自动切换到住宅代理。也可以强制使用 datacenter 或 residential。

## `proxyGroups` (type: `array`):

Apify 代理组。RESIDENTIAL 是已验证默认值，DATACENTER 更便宜但更容易被拦截。

## `minCommentsPerPost` (type: `integer`):

密度保护。已知公开评论少于该值时提前停止，0 表示关闭。

## `startCursorByPost` (type: `object`):

从上次运行摘要中的 `{endCursor}` 继续。不要把不同帖子的游标混用。

## Actor input object example

```json
{
  "postUrls": [
    "https://www.facebook.com/humansofnewyork/posts/pfbid0BbKbkisExKGSKuhee9a7i86RwRuMKFC8NSkKStB7CsM3uXJuAAfZLrkcJMXxhH4Yl"
  ],
  "maxCommentsPerPost": 300,
  "maxPostsPerRun": 5,
  "maxConcurrency": 5,
  "queryMode": "FRESH_LIST",
  "unionSorts": true,
  "commentsSortOrder": "MOST_RELEVANT",
  "failOnEmpty": false,
  "includePostText": false,
  "includeReplies": true,
  "maxReplyThreadsPerPost": 20,
  "maxRepliesPerPost": 200,
  "pageDelayMs": 1000,
  "maxPagesPerPost": 60,
  "introDelayMs": 1500,
  "proxyCountry": "US",
  "proxyTier": "auto",
  "proxyGroups": [
    "RESIDENTIAL"
  ],
  "minCommentsPerPost": 0,
  "startCursorByPost": {}
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `summary` (type: `string`):

No description

# 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 = {
    "postUrls": [
        "https://www.facebook.com/humansofnewyork/posts/pfbid0BbKbkisExKGSKuhee9a7i86RwRuMKFC8NSkKStB7CsM3uXJuAAfZLrkcJMXxhH4Yl"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("spbotdel/facebook-comments-cn").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 = { "postUrls": ["https://www.facebook.com/humansofnewyork/posts/pfbid0BbKbkisExKGSKuhee9a7i86RwRuMKFC8NSkKStB7CsM3uXJuAAfZLrkcJMXxhH4Yl"] }

# Run the Actor and wait for it to finish
run = client.actor("spbotdel/facebook-comments-cn").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 '{
  "postUrls": [
    "https://www.facebook.com/humansofnewyork/posts/pfbid0BbKbkisExKGSKuhee9a7i86RwRuMKFC8NSkKStB7CsM3uXJuAAfZLrkcJMXxhH4Yl"
  ]
}' |
apify call spbotdel/facebook-comments-cn --silent --output-dataset

```

## MCP server setup

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

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/ho0FKSLXHGbMQ2TFT/builds/92VB2N8Ls9bh0tKe6/openapi.json
