Last active
February 3, 2018 15:30
-
-
Save tomger/d05791c9c4a8491a87291b6f5b732b6f to your computer and use it in GitHub Desktop.
Yet another tweet deleter, the other gists didn't work for me.
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
import sys | |
import tweepy # pip install tweepy | |
# options | |
dry_run = True | |
# Twitter API credentials | |
# Go to https://apps.twitter.com | |
consumer_key = "" | |
consumer_secret = "" | |
access_key = "" | |
access_secret = "" | |
doomed_tweets = [] | |
auth = tweepy.OAuthHandler(consumer_key, consumer_secret) | |
auth.set_access_token(access_key, access_secret) | |
api = tweepy.API(auth) | |
# Queue tweet ids | |
for tweet in tweepy.Cursor(api.user_timeline).items(): | |
sys.stdout.write("Queuing (%d)\r" % len(doomed_tweets)) | |
sys.stdout.flush() | |
doomed_tweets.append(tweet.id) | |
print "Queued %d tweets." % len(doomed_tweets) | |
if dry_run: | |
print "Set dry_run to False to delete the queued tweets." | |
sys.exit() | |
# Delete queued tweet ids | |
destroy_count = 0 | |
for tweet in doomed_tweets: | |
sys.stdout.write("Deleting (%d)\r" % destroy_count) | |
sys.stdout.flush() | |
api.destroy_status(tweet) | |
destroy_count += 1 | |
print "Deleted %d tweets." % destroy_count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment