技能圖譜SKILLSGROVE
技能圖譜/影片製作/leamsigc/ShortsGenerator/facebook-research-scrape

facebook-research-scrape

安裝

$npx skills add https://github.com/leamsigc/ShortsGenerator --skill facebook-research-scrape
$git clone --depth 1 https://github.com/leamsigc/ShortsGenerator.git /tmp/ShortsGenerator && mkdir -p ~/.claude/skills && cp -r /tmp/ShortsGenerator/skills/facebook-research-scrape ~/.claude/skills/facebook-research-scrape
請幫我安裝這個 Agent Skill:https://github.com/leamsigc/ShortsGenerator/tree/7e4e16b8c5cb51f61836265189e3a89282228e40/skills/facebook-research-scrape ,先閱讀它的 SKILL.md 和指令碼,確認安全後再安裝到我的技能目錄。

簡介

原文描述 · MITScrape state — runs the Facebook scraper via Chrome DevTools Protocol. Extracts page-level analytics (followers, engagement), top video posts, engagement metrics, and hook screenshots. Also scrapes competitor pages, computes engagement ratios, and saves a historical snapshot for trend comparison across analysis rounds.
以下 SKILL.md 內容轉載自 leamsigc/ShortsGenerator(提交 7e4e16b),依據 MIT 許可證轉載正文(文字未改動;僅省略檔案頭後設資料、將圖片顯示為連結,超長內容會截斷);版權歸 2024 leamsigc 所有。許可證:LICENSE。僅展示說明檔案,附帶指令碼請在原倉庫檢視。

Facebook Research — Scrape State (v3)

Scrapes a Facebook page and its competitors. Requires Chrome running with --remote-debugging-port=9222 and Facebook logged in.

Before running

Ensure:

  1. Chrome is open with --remote-debugging-port=9222 flag
  2. Facebook is logged in (tab stays open)
  3. Config exists at .fb-research/projects/<project-name>/config.json (from setup)

Run

# via global skill (Muse ~/.claude/skills/, also read by Opencode):
node "$CLAUDE_SKILL_ROOT/scripts/scrape.js" <project-name> [sessionId] --session $SESSION
# local dev fallback:
node ./skills/facebook-research/scripts/scrape.js <project-name> --session $SESSION
# dataRoot auto-resolved from CWD walk-up; override: --data-root /path/to/.fb-research

Important: Keep the Facebook tab in the foreground (visible, not minimized) while this runs. Chrome throttles background tabs and screenshots will fail.

What the script does

  1. Navigates to the page (config.pageUrl), extracts page stats (followers, likes, category, description)
  2. Opens the Videos tab, scrolls to load posts, collects video post URLs + estimated views
  3. Visits each top post and extracts: views, likes, comments, shares, caption, og:title
  4. Computes engagement ratios + composite score and ranks the top 5
  5. Scrapes each competitor (config.competitors) the same way → competitors/<name>/raw-posts.json
  6. Saves page-analytics.json, raw-posts.json, and appends a snapshot to page-analytics-history.json
  7. Computes the trend vs the previous snapshot (up/down/stable per metric)

Important note on Facebook's DOM

Facebook uses randomized class names. The script always uses aria-label, role, text matching, and [href*="..."] partial URL selectors — never hardcode class names.

Manual fallback (Chrome DevTools CLI)

If the script gets insufficient data, scrape manually:

  1. chrome-devtools navigate_page --url "https://www.facebook.com/<page_name>/"
  2. Scroll + extract page stats / video links via evaluate_script
  3. Navigate into each post for metrics + take hook screenshots
  4. Save page-analytics.json / raw-posts.json with the same schema

Or use WebSearch fallback: websearch "site:facebook.com <page_name> best performing videos 2026" and note data came from search.

Output

.fb-research/projects/<project-name>/
├── page-analytics-history.json          # Global history (appended each run)
├── latest.json                            # -> <YYYY-MM-DD_HHMMSS>
└── <YYYY-MM-DD_HHMMSS>/                  # This run (dated)
    ├── page-analytics.json                # This run stats + top5
    ├── raw-posts.json                     # Full scanned posts
    └── competitors/<name>/raw-posts.json
# plus legacy copies at project root for back-compat

Next step: skill facebook-research-analyze

檢視許可證全文(MIT)
MIT License

Copyright (c) 2024 leamsigc

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.