Skip to main content
FB Reels Scraper Banner

Awesome Discord PyPI version Python versions License: MIT GitHub followers

A robust, two-stage Facebook Reels scraper that operates through your existing browser session via a lightweight Chrome/Edge extension and a local Python WebSocket bridge.

By utilizing your real browser session, you completely bypass login hurdles, 2FA prompts, fingerprinting, and bot-detection challenges without needing credentials or headless automation drivers.


✨ Features

  • No Bot Detection / Captchas: Works directly inside your logged-in browser tab.
  • Two-Phase Architecture:
    1. Phase 1 (Discovery & Harvest): Scrolls target profile or page reels feeds (/reels/) to collect reel permalinks.
    2. Phase 2 (Deep Extraction): Navigates to individual reel view pages, automatically clicks "See more" / "...more" to un-truncate descriptions, and extracts the full caption text.
  • Local Smart Caching (reels_cache.json): Automatically saves extracted reels on the fly. Re-running the script skips previously scraped URLs to save time and bandwidth.
  • Bundled Chrome Extension: Extension files are packaged directly inside the package and can be exported with a single CLI command (fb-reels-scraper --install-extension).
  • Resilient WebSocket Bridge: Gracefully handles page transitions, DOM reloads, and tab navigation events without throwing disconnect exceptions.

📦 Installation

From PyPI

pip install fb-reels-scraper

Or from source (Editable mode)

git clone https://github.com/ishandutta2007/fb-reels-scraper.git
cd fb-reels-scraper
pip install -e .

🚀 Quick Setup & Usage

Step 1: Export & Load the Browser Extension

If installed via pip, you can export the bundled extension directory into your current working folder:

fb-reels-scraper --install-extension

(Or check the internal extension path via fb-reels-scraper --extension-path)

  1. Open your Chromium browser (Chrome, Brave, Edge, etc.) and go to chrome://extensions/ (or edge://extensions/).
  2. Toggle on Developer mode in the top-right corner.
  3. Click Load unpacked and select the exported ./fb_reels_extension folder (or ./extension if running from source).

Step 2: Open Facebook & Run the CLI

  1. Ensure you have an active Facebook tab open in your browser where you are logged in.
  2. In your terminal, run the CLI tool:
# Run with default fallback user (nadeemkhancyber) and scroll count (20)
fb-reels-scraper

# Scrape a specific user, page name, or handle
fb-reels-scraper --user zuck

# Short flag with custom scrolls and custom cache file
fb-reels-scraper -u zuck -s 25 -c zuck_reels.json

🛠️ CLI Options Reference

Flag Short Default Description
--user -u nadeemkhancyber Facebook username, handle, or page name (e.g. zuck or nadeemkhancyber)
--scrolls -s 20 Number of scroll cycles on the grid to harvest links
--cache-file -c reels_cache.json Path to JSON file where results are cached
--host 127.0.0.1 WebSocket server bind host
--port -p 8765 WebSocket server bind port
--install-extension ./fb_reels_extension Export the bundled extension to a local directory for browser loading
--extension-path — Print absolute path to the bundled extension directory
--help -h — Display help text and usage instructions

🐍 Python Library Usage

You can also import and use fb-reels-scraper programmatically in your own Python scripts:

import asyncio
from fb_reels_scraper import scrape_fb_reels, start_server

async def main():
    server = await start_server(host="127.0.0.1", port=8765)
    try:
        results = await scrape_fb_reels(
            target_url="https://www.facebook.com/example/reels/",
            max_scrolls=10,
            cache_file="reels_cache.json"
        )
        print(f"Scraped {len(results)} reels!")
    finally:
        server.close()
        await server.wait_closed()

asyncio.run(main())

📁 Repository Structure

fb-reels-scraper/
├── pyproject.toml               # Modern PEP 517/621 packaging metadata
├── MANIFEST.in                  # Manifest including non-Python extension assets
├── fb_reels_scraper/            # Core Python package
│   ├── __init__.py
│   ├── __main__.py              # python -m fb_reels_scraper support
│   ├── cli.py                   # CLI entrypoint for fb-reels-scraper command
│   ├── scraper.py               # WebSocket bridge & scraping logic
│   └── extension/               # Bundled Chrome Extension (Manifest V3)
│       ├── manifest.json
│       ├── content.js
│       ├── popup.html
│       └── popup.js
├── reels_cache.json             # Cached results
└── README.md

💾 Cache Format

Descriptions are saved to reels_cache.json in UTF-8 format:

{
  "https://www.facebook.com/reel/123456789012345/": "Here is the full description and caption of the reel...",
  "https://www.facebook.com/reel/987654321098765/": "[No description found]"
}

🚀 Publishing to PyPI

This repository includes a GitHub Actions workflow (.github/workflows/publish.yml) that automatically builds and publishes the package to PyPI whenever a new version tag is pushed.

1. Configure PyPI Authentication (One-time Setup)

You can authenticate via Trusted Publishing (Recommended by PyPI) or an API Token:

  • Option A: Trusted Publishing (OIDC - Recommended):

    1. Go to your project on PyPI (or add a pending publisher before your first release).
    2. Add a new publisher with:
      • Owner: your GitHub username or organization (e.g. ishandutta2007)
      • Repository: fb-reels-scraper
      • Workflow name: publish.yml
      • Environment name: pypi
  • Option B: PyPI API Token:

    1. Generate an API token on PyPI Account Settings.
    2. In your GitHub repository, navigate to Settings ➔ Secrets and variables ➔ Actions.
    3. Create a secret named PYPI_API_TOKEN and paste your token value.

2. Release a New Version

When you are ready to publish an update:

  1. Bump the version in pyproject.toml and fb_reels_scraper/__init__.py:
    # pyproject.toml
    version = "1.0.2"
    
    # fb_reels_scraper/__init__.py
    __version__ = "1.0.2"
    
  2. Commit the change, tag the release, and push to GitHub:
    git commit -am "Bump version to 1.0.2"
    git tag v1.0.2
    git push origin main --tags
    
  3. GitHub Actions will automatically trigger, build the wheel and source tarball, and publish them to PyPI.

💖 Support & Sponsor

Thank you for using and supporting this project! If this tool saved you time or helped in your workflow, please consider:

  • ⭐ Starring the repository on GitHub
  • 🍴 Forking and contributing features or improvements
  • 📢 Sharing it with friends and fellow developers
  • ☕ Buying a coffee / Sponsoring via the GitHub Sponsors Dashboard to support continuous maintenance and new features.

📈 Star History

Star History Chart


🛡️ License

This project is licensed under the MIT License.

Metadata

Release files for fb-reels-scraper 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fb-reels-scraper 1.0.2
File Size Uploaded Provenance Actions
fb_reels_scraper-1.0.2.tar.gz 16.8 kB Without provenance Details for fb_reels_scraper-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fb-reels-scraper 1.0.2
File Interpreter ABI Platform Actions
fb_reels_scraper-1.0.2-py3-none-any.whl Python 3 none any Details for fb_reels_scraper-1.0.2-py3-none-any.whl

Total release size: 31.6 kB

Release files / fb_reels_scraper-1.0.2.tar.gz

Download URL fb_reels_scraper-1.0.2.tar.gz
Size 16.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7395fe51b06f7db94f78bead5921517b21b1d051b1d0aa10c9484129ec10265e
BLAKE2b-256 checksum
How to use checksums
94c42cdc84bdaf24149d507526080c01420aca9a88860eef4fe033de77429a08
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / fb_reels_scraper-1.0.2-py3-none-any.whl

Download URL fb_reels_scraper-1.0.2-py3-none-any.whl
Size 14.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
30966d507a28e95d80728ea1d6d9be519788e56f64650ffe954113f9e94ebdd4
BLAKE2b-256 checksum
How to use checksums
7e0a1b756905bace679bcd5500f2c63f946451454e8a870e81f17c5260e6d6e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for fb-reels-scraper 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page