73 lines
2.3 KiB
Markdown
73 lines
2.3 KiB
Markdown
# Facebook to RSS Scraper
|
|
|
|
This tool scrapes public posts from a Facebook page and converts them into an RSS feed (.xml). It can be run locally or automated using GitHub Actions.
|
|
|
|
## Prerequisites
|
|
|
|
- Python 3.9+
|
|
- pip (Python package installer)
|
|
|
|
## Local Installation & Usage
|
|
|
|
1. **Clone the repository:**
|
|
```bash
|
|
git clone <repository-url>
|
|
cd fb-rss-bridge
|
|
```
|
|
|
|
2. **Install dependencies:**
|
|
It is recommended to use a virtual environment.
|
|
```bash
|
|
python3 -m venv .venv
|
|
source .venv/bin/activate
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
3. **Run the scraper:**
|
|
```bash
|
|
python3 main.py <page_name>
|
|
```
|
|
|
|
Replace `<page_name>` with the Facebook page ID or username.
|
|
|
|
**Options:**
|
|
- `--output`: Specify output file name (default: `feed.xml`)
|
|
- `--pages`: Number of pages to scrape (default: 1)
|
|
|
|
**Example:**
|
|
```bash
|
|
python3 main.py GitHub --pages 2 --output github_feed.xml
|
|
```
|
|
|
|
## GitHub Actions Automated Feed (Free Cloud Solution)
|
|
|
|
This repository is configured to run automatically on GitHub's free tier for public repositories.
|
|
|
|
1. **How it works:**
|
|
- The `.github/workflows/update_feed.yml` file defines a "cron job" that runs every 6 hours.
|
|
- It spins up a temporary server (runner), installs Python, runs the script, and saves the `feed.xml` back to your code.
|
|
- This entire process is free for public repositories on GitHub.
|
|
|
|
2. **Configuration:**
|
|
The workflow is scheduled to run every 6 hours. You can customize the target Facebook page in `.github/workflows/update_feed.yml`:
|
|
```yaml
|
|
env:
|
|
FB_PAGE_NAME: "GitHub" # Change this to the desired page ID/username
|
|
```
|
|
|
|
3. **Getting your RSS Link:**
|
|
To make the generated `feed.xml` accessible to your RSS reader, you must enable **GitHub Pages**:
|
|
|
|
1. Go to your repository **Settings** tab.
|
|
2. On the left sidebar, click **Pages**.
|
|
3. Under **Build and deployment** / **Branch**, select `main` (or `master`) and click **Save**.
|
|
4. Wait a minute or two. GitHub will deploy your site.
|
|
5. Your RSS feed URL will be:
|
|
```
|
|
https://<your-username>.github.io/<repo-name>/feed.xml
|
|
```
|
|
|
|
**Example:**
|
|
If your username is `nthrm` and the repo is `fb-rss-bridge`, the link is:
|
|
`https://nthrm.github.io/fb-rss-bridge/feed.xml`
|