Simple python script using praw API to mass delete reddit submissions and/or comments.
- Supports login without password (OAuth), no need to disable 2FA
- Multiprocessing
- Redacts your messages (edit to something else) before deletion to prevent archiving.
- Requires only praw and Python 3.5+ (runs on Windows/macOS/Linux). This project is intended to use minimum dependencies to offer longevity, better support and compatibility
git clone https://github.com/jogerj/reddit-purge.git
cd reddit-purge
pip -r install requirements.txt
- Configure
run.py
(see below)
- Goto User Settings > Privacy & Security > App Authorization > 'Create App' (Preview)
- Enter any name for your script (default =
PurgeBot
) - Set type to
script
- Enter
http://localhost:8080
as redirect url. (You can leave the rest blank) - Click Create
Use the script name, 14 chars client ID, and 30 chars key you're shown, enter them in run.py
.
username = '' # optional
password = '' # optional
user_agent = 'PurgeBot'
client_id = 'CLIENTIDq00zTA'
client_secret = 'SECRETswQ_r0u7ftiKlVojc4SECRET'
If username and/or password are left blank, OAuth will be used to acquire an access token.
If you encounter issues with secret key length (due to updating), delete the app from reddit and grab new API keys. Reddit recently changed secret key length from 27 to 30 chars.
Disclaimer: Configuration above is only an example. You will need to setup your own configuration!
Run with python3 run.py
Options | Description |
---|---|
limitation = None |
Number of recent comments/submissions to delete. Set to None if no limits (purge ALL comments/submissions). Set to 10 will purge recent 10, etc. |
purge_comments = True purge_submissions = True |
Set to False to not purge comments/submissions. |
redact_msg = "[redacted]" |
Edit comments/submissions to this before deletion. This prevents archiving. |
redact_only = False |
Set to True to only edit posts to redact_msg without deleting them. |
use_multiprocessing = True |
Use multiprocessing. Set to False if problems occur |
show_comment = True |
Show comment body |
show_title = True |
Show submission titles |
controversial_first = True |
Start purge from controversial first instead of newest |
max_score = None |
Only purge posts with score <= max_score . Set to None if no threshold |
no_prompt = False |
Set to True to not prompt at all. Use with EXTRA caution! |
comment_whitelist = [] submissions_whitelist = [] |
Whitelist by ID e.g. ['id1', 'id2', 'id3'] |
debug = False |
Debug mode |
Add whitelistingUsewhitelist.txt
- Use
.cfg
file - Logging deleted posts
- Request your reddit data (if you want to backup before deletion)
- pip installation
- praw
- Original code based on this post in r/learnpython