Skip to content

A Python script for automating Facebook login, searching for topics, and retrieving post content, reactions, comments, and shares using Playwright.

Notifications You must be signed in to change notification settings

Ibrahimghali/Facebook-Scraper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Facebook Scraper

Facebook Scraper is a Python script designed to automate the process of logging into Facebook, searching for specific topics, and retrieving post content along with reactions, comments, and shares using the Playwright framework. This project demonstrates how to use Playwright for web scraping and automation tasks.

Features

  • Log in to Facebook securely using environment variables for credentials.
  • Search for topics and filter results by date.
  • Retrieve and display post content, reactions, comments, and shares.
  • Handles dynamic content loading and pagination.

Requirements

  • Python 3.x
  • playwright
  • python-dotenv

Installation

  1. Clone the repository:

    git clone https://github.com/Ibrahimghali/Facebook-Scraper.git
    cd Facebook-Scraper
  2. Create and activate a virtual environment:

    python3 -m venv .venv
    source .venv/bin/activate  # On Windows use: .venv\Scripts\activate
  3. Install the required packages:

    pip install -r requirements.txt
  4. Install Playwright browser binaries:

    playwright install

Setup

  1. Create a .env file in the root directory of the project.

  2. Add your Facebook credentials to the .env file:

    FACEBOOK_EMAIL=[email protected]
    FACEBOOK_PASSWORD=your_password

Usage

  1. Run the scraper:

    python3 facebook_scraper.py
  2. The script will:

    • Log in to Facebook using the credentials provided.
    • Search for a specified topic.
    • Retrieve and display post content, reactions, comments, and shares.

Notes

  • Ensure you comply with Facebook's terms of service and privacy policies.
  • The script interacts with the Facebook web interface, which may change over time and affect the script's functionality.

In Progress

This project is currently a work in progress. Contributions and improvements are welcome! Feel free to submit issues or pull requests.

Contact

For any questions or issues, please contact [email protected].

About

A Python script for automating Facebook login, searching for topics, and retrieving post content, reactions, comments, and shares using Playwright.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages