# 如何把 Facebook 公开主页帖子下的评论导出成 CSV

[规范网址](https://social2api.com/guides/facebook-export-public-post-comments/)

取得 Facebook 公开主页帖子 ID 后，给 Social2api 的 Facebook 帖子评论列表传 id。若只有公开帖子链接，先用详情查到 id。通读响应并从 data.items 导出评论正文与可用作者名。

DataXAPI 价目生效日期与版本 [2026-11-25 · v22](https://social2api.com/pricing-catalog.json)

## Agent 提示词

~~~~text
请用 Social2api 完成这个任务：如何把 Facebook 公开主页帖子下的评论导出成 CSV。
先请我确认输入（一个 Facebook 公开主页帖子的 ID 或官方 HTTPS 链接）和愿意付费的请求数。使用此页列出的扩展 API 及参数。
只读取允许公开访问的数据，保留可复核的 ID、warnings 和缺失字段，按此格式交付：以评论 ID 为键生成 CSV，保留正文、发布时间、可用作者显示名、关联帖子 ID 和支持时返回的评论链接。。
如果 API 没有返回相应的公开数据，请保留缺失并解释覆盖范围。
https://social2api.com/guides/facebook-export-public-post-comments/
~~~~

[查看 Facebook 帖子评论列表 API 的参数与示例](https://social2api.com/docs/api/catalog-facebook-posts-comments-list/)

## 本页用到的 Social2api 接口

| 接口与参数文档 | 用途 |
| --- | --- |
| [Facebook 帖子评论列表](https://social2api.com/docs/api/catalog-facebook-posts-comments-list/) · GET /v1/facebook/posts/comments/list | Facebook 帖子评论列表。返回一页 data.items，以及可用的下一页游标。 |
| [Facebook 帖子详情](https://social2api.com/docs/api/catalog-facebook-posts-get/) · GET /v1/facebook/posts/get | Facebook 帖子详情。返回一个 data.item 对象或 null。 |

## 准备输入并完成取数

1. 确认目标是可公开访问的主页帖。已有帖子 ID 时直接查评论；手里只有链接时先读取帖子详情。
2. 保存每页 data.items 的原始数据，跟着评论接口返回的游标读取所需页数。只使用实际返回的公开作者名和正文。
3. 按 id 合并并去重，把已取到的评论写入 CSV。如果 parent\_id 为空且无法从结果确认结构，就保留为空。

## 复制 Social2api 请求

在运行环境设置有 catalog 权限的 SOCIAL2API\_API\_KEY 和自己的 DATAXAPI\_API\_KEY。下方请求走 DataXAPI 通道，用公开示例输入展示可运行的请求，执行时会产生供应商请求。替换为自己的公开目标即可。

示例使用接口文档的帖子 ID 请求评论第一页。若手上是一个公开链接，先向帖子详情接口传 url 并从 data.item.id 取值。

~~~~bash
set -eu
: "${SOCIAL2API_API_KEY:?Set a Social2api catalog key}" "${DATAXAPI_API_KEY:?Set a DataXAPI key}"

curl --fail-with-body --silent --show-error --get "https://social2api.com/v1/facebook/posts/comments/list" \
  --header "Authorization: Bearer $SOCIAL2API_API_KEY" \
  --header "X-DataXAPI-Key: $DATAXAPI_API_KEY" \
  --header 'X-Max-Price: 0.002' \
  --data-urlencode 'id=1650176549811048' -o page.json
jq -e '.code == "ok" and (.data.items | type == "array")' page.json >/dev/null
CSV_TMP=$(mktemp facebook-comments.csv.XXXXXX)
trap 'rm -f "$CSV_TMP"' EXIT
jq -r 'def spreadsheet_cell: if type != "string" then . elif test("^\\s*[=+@-]") then "\u0027" + . else . end; (["comment_id","post_id","text","author_name","published_at","url"] | @csv), (.data.items[] | [.id, .post_id, .text, .author.name, .published_at, .url] | map(spreadsheet_cell) | @csv)' page.json > "$CSV_TMP"
mv "$CSV_TMP" facebook-comments.csv
~~~~

## 核对结果与覆盖

以评论 ID 为键生成 CSV，保留正文、发布时间、可用作者显示名、关联帖子 ID 和支持时返回的评论链接。

列表由上游返回的公开评论构成。私密个人动态、私密群组、广告后台以及未返回的回复不在本流程的交付范围内。

## 核对分页和调用费用

若先查一次帖子详情，再取三页评论，四次请求的 DataXAPI 参考费用是 US$0.008。仅查评论时可从已有 ID 开始。

只在 page.has\_more 为 true 且存在 page.next\_cursor 时继续。下一页将该游标原样作为 cursor，继续使用相同查询和供应商。

上游费用从自己的 DataXAPI 账户结算，上游尝试会计入 Social2api 调用用量。展示价格以本站价格清单为准。

| 接口 | DataXAPI 通道参考价与上限 |
| --- | --- |
| [Facebook 帖子评论列表 API](https://social2api.com/docs/api/catalog-facebook-posts-comments-list/) | 每页最多 10 条，每页 US$0.002 |
| [Facebook 帖子详情 API](https://social2api.com/docs/api/catalog-facebook-posts-get/) | 每次 US$0.002 |

## 接口文档

- [Facebook 帖子评论列表 API](https://social2api.com/docs/api/catalog-facebook-posts-comments-list/)
- [Facebook 帖子详情 API](https://social2api.com/docs/api/catalog-facebook-posts-get/)

## 参考来源

- [Social2api 扩展接口计费清单](https://social2api.com/pricing-catalog.json)

## 相关用户讨论

- [将 Facebook 公开帖评论和可用作者名导入 Excel 的需求](https://www.reddit.com/r/excel/comments/gmq3m6/)
- [获取 Facebook 公开主页上的留言的需求](https://www.reddit.com/r/webscraping/comments/lgf63p/)

## 相关指南和问答

- [社媒评论 API](https://social2api.com/roles/posts-comments-list/)

[查看 Facebook 帖子评论列表 API 的参数与示例](https://social2api.com/docs/api/catalog-facebook-posts-comments-list/)
