Skip to content

Instantly share code, notes, and snippets.

@bclavie
Last active April 17, 2016 21:25
Show Gist options
  • Save bclavie/935aa49410d29d9460a50915ac853f58 to your computer and use it in GitHub Desktop.
Save bclavie/935aa49410d29d9460a50915ac853f58 to your computer and use it in GitHub Desktop.
Python 3.x script to wipe all tweets from a twitter account. Requires tweepy.
import tweepy
"""Consumer key&secret key from http://dev.twitter.com"""
CONSUMER_KEY = ''
CONSUMER_SECRET = ''
def login(consumer_key, consumer_secret):
logon = tweepy.OAuthHandler(consumer_key, consumer_secret)
logonurl = logon.get_authorization_url()
"""Authenticate tweet deleter"""
verify_code =input("Please login at %s and enter your verification code here > " % longonurl)
logon.get_access_token(verify_code)
return tweepy.API(logon)
def deletetweets(api):
print ('This will permanently delete all of @%s\'s posts.\nThere is no way to undo this!\nWrite yes to continue.' % api.verify_credentials().screen_name)
do_delete = input("> ")
if do_delete.lower() == 'yes':
for tweet in tweepy.Cursor(api.user_timeline).items():
try:
api.destroy_status(tweet.id)
print ("Tweet deleted: ", tweet.id)
except:
print ("Failed to delete: ", tweet.id)
else:
quit()
if __name__ == "__main__":
session = login(CONSUMER_KEY, CONSUMER_SECRET)
print ("Logged in as: %s" % api.me().screen_name)
deletetweets(session)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment