Staff Meme Scraper (Python) useful for those running meme pages/groups/socials

Luckyy Vendetta

Administrator
Staff
Luckyy Rep
1
0
0
Rep
1
Luckyy Vouches
2
0
0
Vouches
2
Posts
315
Likes
29
5 YEARS
5 YEARS OF SERVICE
LEVEL 500 XP
What it does
------------
- Scrapes hot posts from popular meme subreddits (configurable)
- Filters for direct images (jpg/png/gif/webp), skips galleries/videos
- Asks you how many memes to download each run (you choose X)
- Saves images into a local folder with clean filenames
- De-duplicates across runs and logs metadata

Requirements
------------
- Python 3.8+ installed
- Internet access from the machine running the script

Quick Start (Linux/Ubuntu)
--------------------------
# 1) Install Python + pip (if needed)
sudo apt update
sudo apt install -y python3 python3-pip

# 2) Put your script in a folder, e.g. /home/youruser/meme-bot/
# Save it as meme.py

# 3) Install dependencies
python3 -m pip install requests

# 4) Run it
python3 meme.py
# When prompted: "How many memes would you like to download?" type a number (e.g., 10)

Quick Start (Windows)
---------------------
:: 1) Install Python 3 from python.org (add Python to PATH during setup)

:: 2) Put meme.py somewhere, e.g. C:\meme-bot\meme.py

:: 3) Open Command Prompt and install dependency:
python -m pip install requests

:: 4) Run:
python meme.py
:: Enter how many memes to download (e.g., 10) when prompted

Default Output
--------------
- Images are saved to: ./memes_out/ (next to meme.py)
- Download state file: memes_out/meme_state.json (prevents duplicates)
- Metadata log (one JSON per line): memes_out/meme_metadata.jsonl

Change Subreddits, Filters, or Folder
-------------------------------------
Open meme.py and edit these variables near the top (optional):
SUBREDDITS = ["memes", "dankmemes", "wholesomememes"]
MIN_UPVOTES = 100
OUTPUT_DIR = Path("memes_out")

How to Use (Step-by-Step)
-------------------------
1. Run the script: python3 meme.py (Linux/macOS) or python meme.py (Windows)
2. When asked “How many memes would you like to download?”, type the number you want (e.g., 25) and press Enter.
3. The script fetches top image posts, saves them, and prints a summary.
4. Open the memes_out folder to see your images.

Automate on a Schedule (Optional)
---------------------------------
Linux cron (run every hour, download 10 each time):
cd /home/youruser/meme-bot
echo 10 | /usr/bin/python3 meme.py

Windows Task Scheduler (download 10 each run):
Create a batch file run_meme.bat:
@echo off
cd /d C:\meme-bot
echo 10 | python meme.py

Tips & Notes
------------
- To vary results, occasionally change the number you download or the subreddit list.
- If you see “429 Too Many Requests,” wait a bit between runs (the script already retries politely).
- Filenames are cleaned to avoid OS-unsafe characters.
- If a post is not a direct image (gallery/video), it’s skipped by design.

Troubleshooting
---------------
- requests not found: Install with python3 -m pip install requests
- Permission denied on Linux: Run from your home folder or ensure you have write permission where memes_out is created.
- No new memes found: You might have downloaded the current hot ones already; wait a while or increase the subreddit list / lower MIN_UPVOTES.
- SSL/Cert errors on Windows: Update Python and Windows certificates, or try running in PowerShell as admin once.

FAQ
---
- Where do I change how many memes it downloads? It asks you each run. For automation, pipe a number like echo 10 | python meme.py.
- Can I include more subs? Yes—edit the SUBREDDITS list in meme.py.
- Can it skip low-effort memes? Raise MIN_UPVOTES in meme.py.
- Where are logs? Check meme_metadata.jsonl and your terminal output (or meme_cron.log if using cron).

Credits
-------
This script queries Reddit’s public JSON endpoints and saves direct-image posts only.


9K6HuOL.gif


You must reply before you can see the hidden data contained here.
 
Last edited:

99

373

461

17

Top