Delete all saved reddit links: https://lewery.ca/automation/delete-all-saved-reddit-links
This file contains 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
""" | |
Delete all saved posts and comments on your reddit account with PRAW. | |
Based on: https://lewery.ca/automation/delete-all-saved-reddit-links | |
This version has argparse removed to remove the command line options and they | |
are instead set here inside of the script. This solved two problems for me: | |
1. Reddit usernames can start with a "-" and argparse does not like that. | |
2. No more password in your shell history | |
Needs Python 3+ and Praw 5.3.0 | |
client_id and client_secret are created on reddit as a locally installed | |
script at https://old.reddit.com/prefs/apps/ | |
""" | |
import praw | |
username = "" | |
password = "" | |
client_id = "" | |
client_secret = "" | |
def run_praw(client_id, client_secret, password, username): | |
print(client_id, client_secret, username) | |
user_agent = "/u/{} delete all saved entries".format(username) | |
r = praw.Reddit(client_id=client_id, client_secret=client_secret, | |
password=password, username=username, | |
user_agent=user_agent) | |
saved = r.user.me().saved(limit=1000) | |
for s in saved: | |
try: | |
s.unsave() | |
except AttributeError as err: | |
print(err) | |
def main(): | |
""" Run the program """ | |
run_praw(client_id, client_secret, password, username) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment