Last active
December 19, 2015 14:17
-
-
Save mpenkov/61c2e051e900bfedd911 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# reddit comment cleaner | |
# Delete my comments from a particular subreddit | |
# | |
import argparse | |
import getpass | |
import praw | |
import logging | |
logging.basicConfig(level=logging.DEBUG) | |
parser = argparse.ArgumentParser() | |
parser.add_argument("username") | |
parser.add_argument("subreddit") | |
parser.add_argument("-l", "--l", dest="limit", type=int, default=10, | |
help="limit the number of comments to delete") | |
args = parser.parse_args() | |
logging.debug("args.limit: %d", args.limit) | |
password = getpass.getpass() | |
reddit = praw.Reddit("test application by /u/mishapenkov") | |
reddit.login(args.username, password) | |
user = reddit.get_redditor(args.username) | |
comments = [c for c in user.get_comments(limit=args.limit) | |
if c.subreddit.display_name == args.subreddit] | |
logging.info("deleting %d comments", len(comments)) | |
for i, comment in enumerate(comments): | |
logging.info("deleted comment %d: %s", i, comment.permalink) | |
comment.delete() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment