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.
- 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.
- Python 3.x
playwright
python-dotenv
-
Clone the repository:
git clone https://github.com/Ibrahimghali/Facebook-Scraper.git cd Facebook-Scraper
-
Create and activate a virtual environment:
python3 -m venv .venv source .venv/bin/activate # On Windows use: .venv\Scripts\activate
-
Install the required packages:
pip install -r requirements.txt
-
Install Playwright browser binaries:
playwright install
-
Create a
.env
file in the root directory of the project. -
Add your Facebook credentials to the
.env
file:FACEBOOK_EMAIL=[email protected] FACEBOOK_PASSWORD=your_password
-
Run the scraper:
python3 facebook_scraper.py
-
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.
- 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.
This project is currently a work in progress. Contributions and improvements are welcome! Feel free to submit issues or pull requests.
For any questions or issues, please contact [email protected].