A Python script to scrape events from Facebook pages and display them in a simple Flask web application.
- Python 3.8 or higher
- pip (Python package installer)
- Git
- Clone the repository:
git clone https://github.com/yourusername/fb-events-scraper.git
cd fb-events-scraper- Create and activate virtual environment:
python -m venv .venv
source .venv/bin/activate # On Linux/Mac
# or
.venv\Scripts\activate # On Windows- Install required packages:
pip install -r requirements.txt- Install Playwright and its dependencies:
playwright install
playwright install-deps
playwright install chrome- Create a CSV file (e.g.,
my_liked_pages.csv) with Facebook pages URLs and categories:
fb_page_link,category
https://facebook.com/your-page-1/upcoming_hosted_events,music,concert
https://facebook.com/your-page-2/upcoming_hosted_events,theater,exhibitionThe category column can contain multiple categories separated by commas. These categories will be used to filter events in the web interface.
- Make sure your virtual environment is activated
- Run the scraper:
python -m fb_events_scraperThe script will:
- Read URLs from your CSV file
- Scrape events from each page
- Save results to
events_data.json
- Ensure you have scraped some events first (events_data.json should exist)
- Start the Flask server:
python app.py- Open your browser and visit:
http://localhost:5000
The web application provides a simple interface to view scraped events:
- Events are grouped by date
- Today's events are highlighted
- Events are sorted chronologically
If you encounter any issues:
- Make sure all dependencies are installed:
pip install -r requirements.txt- Check if Playwright is installed correctly:
playwright install --help- Verify your CSV file format is correct
- Ensure you have proper internet connection
- Check if events_data.json exists before running Flask app
For scrape FB Page links to CSV File - I recommened using this browser extension -> www.webscraper.io
This project is licensed under the MIT License - see the LICENSE file for details.
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
- This scraper is for educational purposes only
- Respect Facebook's terms of service and rate limiting
- Some events might not be accessible due to privacy settings