-
-
Save Epion003/62150b6ea7d7c1448ac0425bd8f47451 to your computer and use it in GitHub Desktop.
This script will delete all of the tweets in a specified account.
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
| # This script will delete all of the tweets in the specified account. | |
| # You may need to hit the more button every now and then as the script runs | |
| # this is due to a bug in twitter.com | |
| import twitter # Requires python-twitter library | |
| username = 'your_username' | |
| password = 'your_password' | |
| count = 200 # Number of statuses in a batch. Twitter API wont allow more than 200 | |
| api = twitter.Api(username=username, password=password) | |
| api.SetCache(None) # Caching needs to be turned off | |
| def delete_tweet(status_id): | |
| """Deletes tweet with matching status_id""" | |
| api.DestroyStatus(status_id) | |
| print "Deleted: " + str(status_id) | |
| batch = 0 # initialise batch counter | |
| while True: # Rinse and repeat | |
| batch += 1 # Increment batch counter | |
| print "\nProcessing batch " + str(batch) | |
| tweets = api.GetUserTimeline(username, count=count) # Get batch of tweets | |
| if not tweets: break # Exit if there aren't any tweets left | |
| [delete_tweet(tweet.id) for tweet in tweets] # Delete tweets in this batch | |
| print "\nDone" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment