Monitor Facebook groups for new posts using Playwright browser automation with stealth mode and persistent login session. Scrapes group feed, tracks seen pos...
Playwright-based headless browser scraper for Facebook groups. Default behavior: captures a stitched "feed strip" (scrolls 3× viewport, crops to feed column, stitches into 1 JPEG) → agent calls vision model once with a custom prompt to extract and interpret all new posts in a single LLM call.
Requires one-time manual login via terminal to establish a persistent browser session.
See references/SETUP.md for installation and first-time login instructions.
scripts/fb-group-monitor.pyscripts/fb-group-monitor.shscripts/.browser-data/ (persistent login)scripts/.seen-posts.json (dedup tracking)scripts/screenshots/ or custom --shots-dirscripts/fb-group-monitor.sh status
Output:
{"success": true, "action": "status", "message": "Session active — logged in to Facebook."}
scripts/fb-group-monitor.sh scrape <GROUP_URL> [--limit N] [--shots-dir <PATH>]
Parameters:
GROUP_URL: Full URL (https://www.facebook.com/groups/123456) or just group ID--limit N: Max posts to scrape (default: 10)--shots-dir <PATH>: ⚠️ REQUIRED for vision — save screenshots in agent workspace so image tool can read them--no-shots: Skip screenshots (faster, text-only mode)Example:
scripts/fb-group-monitor.sh scrape "https://www.facebook.com/groups/123456789" --limit 10 --shots-dir ./temp-screenshots
Output JSON (with feed strip screenshot):
{
"success": true,
"action": "scrape",
"group_name": "Example Group Name",
"group_url": "https://www.facebook.com/groups/123456789",
"total_scraped": 6,
"new_count": 3,
"feed_screenshot": "/path/to/temp-screenshots/feed_abc12345_1741800000.jpg",
"posts": [
{
"author": "Poster Name",
"text": "Post content (may be truncated by Facebook's 'See more')...",
"url": "https://facebook.com/groups/123456/posts/789",
"images": 3
},
{
"author": "Another Poster",
"text": "Text-only post, no images...",
"url": "https://facebook.com/groups/123456/posts/790",
"images": 0
}
],
"message": "Found 3 new posts / 6 total."
}
Note:
feed_screenshotis a single stitched JPEG covering the full feed (3 viewport scrolls). Individual posts no longer have ascreenshot_path— usefeed_screenshot(top-level) instead.
scripts/fb-group-monitor.sh clean-shots
Auto-removes screenshots older than 48h and caps at 100 max. Script also auto-cleans before each scrape.
scripts/fb-group-monitor.sh login
Opens browser, login manually, press Enter to save session. Session lasts weeks/months.
When triggered by cron or user request to check a group:
scripts/fb-group-monitor.sh scrape "<GROUP_URL>" --limit 10 --shots-dir ./temp-screenshots
⚠️ Use
--shots-dirpointing to a path within the workspace so the image tool can access screenshots.
If feed_screenshot is present (1 stitched image covering the full feed):
image and prompt parameters:
image tool:
image: <feed_screenshot path>
prompt: "Facebook group feed. Find and analyze posts by these people (new posts to process):
- [Author 1]: "[first few words of text from JSON]" — N images
- [Author 2]: "[first few words of text from JSON]"
...
For EACH post, do 2 things:
1. EXTRACT: book/product name, author/publisher (read from cover), price (including handwritten prices), condition (new/used/marked/yellowed).
2. INTERPRET: is the deal worth it (price vs market if known), is the item rare/valuable, actual condition assessment from photos."
{} — default prompt just describes the image genericallyurl from JSONtext field ("see more" posts)If feed_screenshot is absent (screenshot failed):
text field of each postMUST include the original post link in each item for verification.
Format per new post:
📌 *[Title/Summary]*
👤 Author: [author]
💰 Price: [price or "unknown"]
📝 Condition: [description]
💡 Note: [deal assessment or insight, if any]
🔗 [post URL]
success == false → report error brieflymessage tool returns an error → report once and stop, do NOT retrylogin from terminalZIP package — ready to use