📦 Facebook Scraper — Facebook 页面和群组爬虫
v0.1.2通过浏览器模拟和地理位置、类别发现公共 Facebook 页面和群组,支持 JSON/CSV 导出。注意:使用前请确认合规性和安全风险。
详细分析 ▾
运行时依赖
版本
facebook-scraper 0.1.2 - 更新 SKILL.md 文档,无功能或特性变化。
安装命令
点击复制技能文档
来自 ScrapeClaw — 一套生产就绪的代理式社交媒体抓取工具,支持 Instagram、YouTube、X/Twitter 和 Facebook,基于 Python 和 Playwright 构建,无需 API 密钥。
基于浏览器的 Facebook 页面和群组发现及抓取工具。
概述
此技能提供两阶段 Facebook 抓取系统:
- 页面/群组发现
- 浏览器抓取
功能
- 🔍 - 按位置和类别发现 Facebook 页面和群组
- 🌐 - 完整浏览器模拟,精确抓取
- 🛡️ - 浏览器指纹、人类行为模拟和隐形脚本
- 📊 - 页面/群组信息、统计、图片和互动数据
- 💾 - JSON/CSV 导出,附带下载的缩略图
- 🔄 - 恢复中断的抓取会话
- ⚡ - 自动跳过私密群组、低赞页面和空档案
- 📂 - 通过 --type 标志支持页面、群组和公开档案
获取 Google API 凭证(可选)
- 前往 Google Cloud Console
- 创建新项目或选择现有项目
- 启用"Custom Search API"
- 创建 API 凭证 → API 密钥
- 前往 Programmable Search Engine
- 创建搜索引擎,以
facebook.com为搜索站点 - 复制搜索引擎 ID
使用方法
代理工具接口
对于 OpenClaw 代理集成,此技能提供 JSON 输出:
# 发现 Facebook 页面(返回 JSON) discover --location "Miami" --category "restaurant" --type page --output json# 发现 Facebook 群组(返回 JSON) discover --location "New York" --category "fitness" --type group --output json
# 抓取单个页面(返回 JSON) scrape --page-name examplebusiness --output json
# 抓取单个群组(返回 JSON) scrape --page-name examplegroup --type group --output json
输出数据
页面/群组数据结构
{
"page_name": "example_business",
"display_name": "Example Business",
"entity_type": "page",
"category": "Restaurant",
"subcategory": "Italian Restaurant",
"about": "Family-owned Italian restaurant since 1985",
"followers": 45000,
...
}
安装
# 克隆仓库 git clone https://github.com/influenza-0/facebook-scraper.git cd facebook-scraper
# 安装依赖 pip install -r requirements.txt
配置
环境变量
# 可选:Google API 凭证(用于高级发现) export GOOGLE_API_KEY="your_api_key" export GOOGLE_CSE_ID="your_cse_id"
# 可选:代理 export HTTP_PROXY="http://proxy:port" export HTTPS_PROXY="http://proxy:port"
运行发现
# 按位置发现页面 python -m src.main discover --location "Los Angeles" --category "restaurant" --type page
# 按类别发现群组 python -m src.main discover --location "San Francisco" --category "technology" --type group
运行抓取
# 抓取页面 python -m src.main scrape --page-name examplebusiness --type page
# 抓取群组 python -m src.main scrape --page-name examplegroup --type group
输出格式
JSON 输出
python -m src.main scrape --page-name examplebusiness --output json
生成 data/output/examplebusiness.json
CSV 输出
python -m src.main scrape --page-name examplebusiness --output csv
生成 data/output/examplebusiness.csv
高级选项
缩略图下载
python -m src.main scrape --page-name examplebusiness --download-thumbnails
恢复中断的会话
python -m src.main scrape --page-name examplebusiness --resume
过滤选项
# 跳过低赞页面 python -m src.main discover --location "Miami" --category "restaurant" --min-likes 1000
# 跳过私密群组 python -m src.main discover --location "New York" --category "fitness" --skip-private
注意事项
- 此工具仅用于抓取公开可访问的内容
- 请遵守 Facebook 的服务条款
- 大规模抓取可能导致 IP 被封,建议使用代理
- 建议在非高峰时段运行
故障排除
浏览器启动失败
确保已安装 Chromium:
playwright install chromium
被检测到为机器人
- 使用
--stealth模式 - 添加延迟:
--delay 2 - 使用代理:
--proxy http://proxy:port
无内容返回
- 检查页面/群组名称是否正确
- 确认页面/群组是公开的
- 尝试使用不同位置或类别