GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - pring-nt/fb-graphql-interceptor: GraphQL Interceptor to extract engagement metrics (number of Reactions, Comments, Shares), post titles, and publication dates from Facebook posts and Reels.

BranchesTags
Open more actions menu

Latest commit

 

History

12 Commits
12 Commits

Folders and files

NameName
Last commit message
Last commit date
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
comment_scraper.py
comment_scraper.py
 
 
save_session.py
save_session.py
 
 
scraper.py
scraper.py
 
 

Repository files navigation

Facebook GraphQL Interceptor

An asynchronous Python tool using Playwright to extract engagement metrics (Reactions, Comments, Shares), post titles, publication dates, and deep comment threads from Facebook posts, photos, and Reels.

Rather than relying purely on DOM elements, this toolkit intercepts background GraphQL network requests to retrieve exact, un-abbreviated counts and raw comment payloads directly from API responses.

Features

  • Network Interception: Captures raw GraphQL payloads to retrieve precise metrics (e.g., 1,542 instead of 1.5K) and full comment text streams in real time.
  • Deep Comment Thread Scraping (comment_scraper.py): Automatically expands collapsed sub-replies, navigates nested comment hierarchies, and links child replies to parent comment IDs.
  • Adaptive Early-Exit Controller: Monitors stream activity to automatically terminate comment loops after consecutive stagnant checks.
  • Session Helper: Includes save_session.py to log in once via an interactive browser window and export your session state to auth.json.
  • Concurrent Processing: Uses Python asyncio and asyncio.Semaphore to process multiple engagement URLs in parallel.
  • Resource Optimization: Blocks heavy static assets (images, video streams, web fonts) to maximize network bandwidth for GraphQL stream processing.
  • Dual Export: Exports high-level post engagement to CSV and structured JSON, and deep comment hierarchies to a dedicated JSON file.

Prerequisites

  • Python 3.8 or higher
  • Playwright for Python

Installation

  1. Clone the repository:

    git clone [https://github.com/pring-nt/fb-graphql-interceptor.git](https://github.com/pring-nt/fb-graphql-interceptor.git)
    cd fb-graphql-interceptor
  2. Install dependencies:

    pip install playwright
  3. Install Chromium browser binary:

    playwright install chromium

Usage

1. Save Session State

An authenticated session (auth.json) is required for deep comment scraping to prevent Facebook from displaying login walls or blocking comment expansion.

python save_session.py

Log in to Facebook in the browser window that opens, then return to your terminal and press Enter to save the session state to auth.json.

2. Prepare Input Links (links.txt)

Create a text file named links.txt containing the Facebook URLs you wish to scrape, one per line. Lines starting with # are ignored.

[https://www.facebook.com/watch/?v=123456789](https://www.facebook.com/watch/?v=123456789)
[https://www.facebook.com/share/v/AbCdEfGhIj/](https://www.facebook.com/share/v/AbCdEfGhIj/)
# Optional comment line
[https://www.facebook.com/photo/?fbid=1722547075703056](https://www.facebook.com/photo/?fbid=1722547075703056)

3. Run Engagement Scraper

Extract high-level post titles, dates, reactions, total comments, and share counts:

python scraper.py

4. Run Deep Comment Scraper

Extract full text comment threads, author names, timestamps, and sub-reply structures:

python comment_scraper.py

Configuration

scraper.py Settings

MAX_CONCURRENT = 3    # Number of browser tabs running in parallel
DELAY_SEC = 2.0       # Pause duration after page navigation

comment_scraper.py Settings

MAX_CONCURRENT = 1            # Keep low to avoid rate limits during deep scrolling
TARGET_COMMENTS_PER_POST = 500# Upper comment capture target per post
MAX_SCROLL_ATTEMPTS = 60      # Maximum scroll ticks allowed per post
MAX_STAGNANT_TICKS = 3        # Exit loop after N consecutive ticks with 0 new comments

Output Data

Engagement Metrics (results.csv & results.json)

  • url: Source URL
  • date: Post publication date (YYYY-MM-DD)
  • title: Post title or caption text
  • reactions: Total reaction count
  • comments: Total comment count
  • shares: Total share count
  • total_engagement: Aggregate engagement sum
  • status / error: Execution status and error logs

Deep Comments (comments_results.json)

[
  {
    "url": "[https://www.facebook.com/photo/?fbid=1722547075703056](https://www.facebook.com/photo/?fbid=1722547075703056)",
    "scraped_at": "2026-08-27T19:28:14.000000",
    "total_comments_captured": 8,
    "status": "ok",
    "error": "",
    "comments": [
      {
        "comment_id": "10161829304928102",
        "author": "Jane Doe",
        "text": "Great post!",
        "date": "2026-08-25 14:22:10",
        "is_reply": false,
        "parent_id": null
      },
      {
        "comment_id": "10161829311204911",
        "author": "John Smith",
        "text": "Agreed with Jane!",
        "date": "2026-08-25 14:30:05",
        "is_reply": true,
        "parent_id": "10161829304928102"
      }
    ]
  }
]

About

GraphQL Interceptor to extract engagement metrics (number of Reactions, Comments, Shares), post titles, and publication dates from Facebook posts and Reels.

Resources

Readme
AGPL-3.0 license
Activity

Stars

2 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.