Skip to content

d00ksky/reddit_meme_scraper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reddit Meme Scraper

🎭 Your Personal Meme Delivery Service

A Python application that scrapes memes from Reddit and sends them via Telegram. This tool automatically collects memes from specified subreddits and forwards them to your Telegram channel or chat.

Features

  • Scrapes memes from multiple subreddits
  • Sends memes via Telegram bot
  • Configurable scheduling
  • Automatic duplicate detection
  • Logging system for monitoring
  • E-ink display support (Raspberry Pi)
  • Cross-platform support (Windows, Linux, Raspberry Pi)

Prerequisites

  • Python 3.8 or higher
  • pip (Python package manager)
  • Reddit API credentials
  • Telegram Bot Token

Quick Installation

🚀 Universal Installer (Recommended)

Linux/Raspberry Pi:

git clone https://github.com/yourusername/reddit_meme_scraper.git
cd reddit_meme_scraper
chmod +x install.sh
./install.sh

Windows:

git clone https://github.com/yourusername/reddit_meme_scraper.git
cd reddit_meme_scraper
install.bat

The installer will:

  • ✅ Detect your platform automatically
  • ✅ Install dependencies (venv for Linux, system-wide for Raspberry Pi)
  • ✅ Set up display support (Raspberry Pi only)
  • ✅ Run interactive setup for API credentials

Manual Installation

Windows

  1. Clone and Run Installer
    git clone https://github.com/yourusername/reddit_meme_scraper.git
    cd reddit_meme_scraper
    install.bat

Raspberry Pi

🍓 Raspberry Pi uses system-wide installation (no venv) for simplicity:

  1. Clone and Install

    git clone https://github.com/yourusername/reddit_meme_scraper.git
    cd reddit_meme_scraper
    chmod +x install.sh
    ./install.sh
  2. Enable as Service

    sudo cp reddit-meme-scraper.service /etc/systemd/system/
    sudo sed -i "s|/home/pi/|$HOME/|g" /etc/systemd/system/reddit-meme-scraper.service
    sudo sed -i "s|User=pi|User=$USER|g" /etc/systemd/system/reddit-meme-scraper.service
    sudo systemctl enable reddit-meme-scraper
    sudo systemctl start reddit-meme-scraper

Ubuntu/Linux

  1. Install with Virtual Environment
    git clone https://github.com/yourusername/reddit_meme_scraper.git
    cd reddit_meme_scraper
    chmod +x install.sh
    ./install.sh

Migrating Existing Installation

If you have an existing venv-based installation on Raspberry Pi:

cd reddit_meme_scraper
chmod +x migrate_to_system.sh
./migrate_to_system.sh

This will migrate your installation to system-wide for better performance and reliability.

Configuration

  1. Reddit API Setup

    • Go to Reddit Apps
    • Click "Create App" or "Create Another App"
    • Fill in the required information
    • Note down the client ID and client secret
  2. Telegram Bot Setup

    • Message @BotFather on Telegram
    • Create a new bot using /newbot
    • Note down the bot token
    • Get your chat ID by messaging @userinfobot
  3. Configure config.json

    {
      "subreddits": ["memes", "dankmemes"],
      "schedule": {
        "interval_hours": 1
      },
      "telegram": {
        "max_memes_per_batch": 5
      }
    }

Usage

Windows

  1. Run the Application

    .\venv\Scripts\python main.py
  2. Run as Windows Service (Optional)

    • Install NSSM (Non-Sucking Service Manager)
    • Create a service:
    nssm install RedditMemeScraper "C:\path\to\venv\Scripts\python.exe" "C:\path\to\main.py"
    nssm start RedditMemeScraper

Fedora/Ubuntu

  1. Run the Application

    source venv/bin/activate
    python3 main.py
  2. Run as Systemd Service (Recommended)

    sudo nano /etc/systemd/system/reddit-meme-scraper.service

    Add the following content:

    [Unit]
    Description=Reddit Meme Scraper Service
    After=network.target
    
    [Service]
    Type=simple
    User=<your-username>
    WorkingDirectory=/path/to/reddit_meme_scraper
    Environment=PATH=/path/to/reddit_meme_scraper/venv/bin
    ExecStart=/path/to/reddit_meme_scraper/venv/bin/python main.py
    Restart=always
    RestartSec=10
    
    [Install]
    WantedBy=multi-user.target

    Enable and start the service:

    sudo systemctl enable reddit-meme-scraper
    sudo systemctl start reddit-meme-scraper

Monitoring

Webhook Notifications

The scraper supports webhook notifications for monitoring via Slack, Discord, or generic webhooks.

  1. Configure in config.json:

    {
      "monitoring": {
        "enabled": true,
        "webhook": {
          "enabled": true,
          "url": "https://hooks.slack.com/services/YOUR/WEBHOOK/URL",
          "type": "slack"
        }
      }
    }
  2. Supported webhook types:

    • slack - Slack incoming webhooks
    • discord - Discord webhooks
    • generic - Custom webhook format
  3. Notifications sent:

    • Startup/shutdown events
    • Daily statistics reports
    • Error alerts
    • Successful meme batches

E-ink Display Support (Raspberry Pi)

Perfect for your Raspberry Pi Zero W with e-ink display! The scraper can show real-time stats on supported e-ink displays.

  1. Setup e-ink display (Raspberry Pi only):

    chmod +x setup_display.sh
    ./setup_display.sh
  2. Enable in config.json:

    {
      "display": {
        "enabled": true,
        "type": "epd2in13_V3"
      }
    }
  3. Supported displays:

    • epd2in13_V3 - 2.13" V3 display (most common for pwnagotchi)
    • epd2in7 - 2.7" display
  4. Display shows:

    • Total memes scraped/sent/failed
    • Last run time
    • System uptime
    • Current status (OK/ERROR)
    • Real-time updates every 5 minutes

Note: The application works perfectly without display support. Display libraries are optional and will be gracefully skipped if not available.

Advanced Configuration

Full config.json example:

{
    "reddit": {
        "subreddits": ["memes", "dankmemes", "wholesomememes"],
        "sort_by": "hot",
        "limit": 10,
        "min_score": 100
    },
    "schedule": {
        "interval_hours": 1
    },
    "filters": {
        "image_only": true,
        "exclude_nsfw": false,
        "max_title_length": 200
    },
    "telegram": {
        "enabled": true
    },
    "monitoring": {
        "enabled": true,
        "webhook": {
            "enabled": true,
            "url": "https://hooks.slack.com/services/YOUR/WEBHOOK/URL",
            "type": "slack"
        }
    },
    "display": {
        "enabled": true,
        "type": "epd2in13_V3"
    }
}

Raspberry Pi Service Management

Basic Service Commands

# Start the service
sudo systemctl start reddit-meme-scraper

# Stop the service
sudo systemctl stop reddit-meme-scraper

# Restart the service
sudo systemctl restart reddit-meme-scraper

# Check service status
sudo systemctl status reddit-meme-scraper

# Enable service to start on boot
sudo systemctl enable reddit-meme-scraper

# Disable service from starting on boot
sudo systemctl disable reddit-meme-scraper

Logging Commands:

# View live logs (follow mode)
journalctl -u reddit-meme-scraper -f

# View last 100 lines of logs
journalctl -u reddit-meme-scraper -n 100

# View logs since last boot
journalctl -u reddit-meme-scraper -b

# View logs from a specific time
journalctl -u reddit-meme-scraper --since "2024-05-28 20:00:00"

# View error logs only
journalctl -u reddit-meme-scraper -p err

Service Configuration

# Edit service configuration
sudo nano /etc/systemd/system/reddit-meme-scraper.service

# Reload systemd after configuration changes
sudo systemctl daemon-reload

# Verify service configuration
sudo systemctl cat reddit-meme-scraper

Troubleshooting Commands

# Check if service is enabled
sudo systemctl is-enabled reddit-meme-scraper

# Check service dependencies
sudo systemctl list-dependencies reddit-meme-scraper

# Check service resource usage
sudo systemctl status reddit-meme-scraper -l

# View detailed service information
sudo systemctl show reddit-meme-scraper

Monitoring (Traditional)

Windows

  • Check the logs in the project directory
  • If running as a service, check Event Viewer

Fedora/Ubuntu

  • View service status:
    sudo systemctl status reddit-meme-scraper
  • View logs:
    journalctl -u reddit-meme-scraper -f

Troubleshooting

  1. Application Not Starting

    • Check if Python is installed correctly
    • Verify all dependencies are installed
    • Check the .env file for correct credentials
  2. No Memes Being Sent

    • Verify Reddit API credentials
    • Check Telegram bot token and chat ID
    • Ensure the bot is added to the target chat/channel
  3. Service Not Starting

    • Check service status and logs
    • Verify file paths in service configuration
    • Ensure correct permissions

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Scraper for reddit that will search top memes and sent them to you on telegram so you don't have to waste time on reddit but can also have new memes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors