- 
      
 - 
        
Save sadanalog/ca53f3c88613f2e09178a294be11ff7d to your computer and use it in GitHub Desktop.  
Revisions
- 
        
davej revised this gist
Jan 25, 2014 . 1 changed file with 5 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -33,8 +33,11 @@ def batch_delete(api): do_delete = raw_input("> ") if do_delete.lower() == 'yes': for status in tweepy.Cursor(api.user_timeline).items(): try: api.destroy_status(status.id) print "Deleted:", status.id except: print "Failed to delete:", status.id if __name__ == "__main__": api = oauth_login(CONSUMER_KEY, CONSUMER_SECRET)  - 
        
davej revised this gist
Aug 15, 2011 . 1 changed file with 34 additions and 28 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,37 +1,43 @@ # -*- coding: utf-8 -*- """ This script will delete all of the tweets in the specified account. You may need to hit the "more" button on the bottom of your twitter profile page every now and then as the script runs, this is due to a bug in twitter. You will need to get a consumer key and consumer secret token to use this script, you can do so by registering a twitter application at https://dev.twitter.com/apps @requirements: Python 2.5+, Tweepy (http://pypi.python.org/pypi/tweepy/1.7.1) @author: Dave Jeffery """ import tweepy CONSUMER_KEY = 'XXX' CONSUMER_SECRET = 'XXX' def oauth_login(consumer_key, consumer_secret): """Authenticate with twitter using OAuth""" auth = tweepy.OAuthHandler(consumer_key, consumer_secret) auth_url = auth.get_authorization_url() verify_code = raw_input("Authenticate at %s and then enter you verification code here > " % auth_url) auth.get_access_token(verify_code) return tweepy.API(auth) def batch_delete(api): print "You are about to Delete all tweets from the account @%s." % api.verify_credentials().screen_name print "Does this sound ok? There is no undo! Type yes to carry out this action." do_delete = raw_input("> ") if do_delete.lower() == 'yes': for status in tweepy.Cursor(api.user_timeline).items(): api.destroy_status(status.id) print "Deleted:", status.id if __name__ == "__main__": api = oauth_login(CONSUMER_KEY, CONSUMER_SECRET) print "Authenticated as: %s" % api.me().screen_name batch_delete(api)  - 
        
davej revised this gist
May 19, 2009 . 1 changed file with 20 additions and 18 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,35 +1,37 @@ # -*- coding: utf-8 -*- """ @requirements: python-twitter (http://code.google.com/p/python-twitter/) and simplejson (http://code.google.com/p/simplejson/) @author: Dave Jeffery This script will delete all of the tweets in the specified account. You may need to hit the "more" button on the bottom of your twitter profile page every now and then as the script runs, this is due to a bug in twitter. """ import twitter, urllib2 def delete_tweet(api, status_id): """Deletes tweet with matching status_id""" api.DestroyStatus(status_id) print "Deleted:", status_id def batch_delete(username, password, batch_size=200): """Fetches tweets in batches and calls delete_tweet on each one""" api = twitter.Api(username, password) api.SetCache(None) # Caching needs to be turned off print "Deleting all tweets from", username batch = 0 while True: # Rinse and repeat tweets = api.GetUserTimeline(username, count=batch_size) # Get batch of tweets if tweets: batch += 1 print "\nProcessing batch", batch for tweet in tweets: delete_tweet(api, tweet.id) elif not tweets: print "\nNo tweets left... Done" break if __name__ == "__main__": batch_delete(username="user", password="pass")  - 
        
davej revised this gist
May 18, 2009 . 1 changed file with 21 additions and 13 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,12 @@ # This script will delete all of the tweets in the specified account. # You may need to hit the 'more' button on the bottom of your twitter profile # page every now and then as the script runs, this is due to a bug in twitter. import twitter # Requires python-twitter library username = 'your_username' password = 'your_password' api = twitter.Api(username=username, password=password) api.SetCache(None) # Caching needs to be turned off @@ -16,12 +15,21 @@ def delete_tweet(status_id): api.DestroyStatus(status_id) print "Deleted:", status_id def batch_delete(batch_size = 200, username = username): """Fetches tweets in batches and calls delete_tweet on each one""" print "Deleting all tweets from", username batch = 0 while True: # Rinse and repeat tweets = api.GetUserTimeline(username, count=batch_size) # Get batch of tweets if tweets: batch += 1 # Increment batch counter print "\nProcessing batch", batch for tweet in tweets: delete_tweet(tweet.id) else: # Exit if there aren't any tweets left print "\nNo tweets left... Done" break batch_delete()  - 
        
davej revised this gist
May 18, 2009 . 1 changed file with 7 additions and 7 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -14,14 +14,14 @@ def delete_tweet(status_id): """Deletes tweet with matching status_id""" api.DestroyStatus(status_id) print "Deleted:", status_id batch = 0 # initialise batch counter while True: # Rinse and repeat batch += 1 # Increment batch counter print "\nProcessing batch", 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"  - 
        
davej revised this gist
May 18, 2009 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -14,12 +14,12 @@ def delete_tweet(status_id): """Deletes tweet with matching status_id""" api.DestroyStatus(status_id) print "Deleted:", str(status_id) batch = 0 while True: # Rinse and repeat batch += 1 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 batch  - 
        
davej revised this gist
May 18, 2009 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -16,12 +16,12 @@ def delete_tweet(status_id): api.DestroyStatus(status_id) print "Deleted: " + str(status_id) batch = 0 while True: # Rinse and repeat batch += 1 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 batch print "\nDone"  - 
        
davej revised this gist
May 18, 2009 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ # This script will delete all of the tweets in the specified account. # You may need to hit the 'more' button on the bottom of your twitter profile # page every now and then as the script runs, this is due to a bug in twitter. import twitter # Requires python-twitter library  - 
        
davej revised this gist
May 18, 2009 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ # This script will delete all of the tweets in the specified account. # You may need to hit the 'more' button on the bottom of your twitter profile # page every now and then as the script runs this is due to a bug in twitter. import twitter # Requires python-twitter library  - 
        
davej revised this gist
May 18, 2009 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,6 @@ # 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  - 
        
davej revised this gist
May 18, 2009 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ # This script will delete all of the tweets in a specified account import twitter # Requires python-twitter library username = 'your_username' password = 'your_password'  - 
        
davej created this gist
May 18, 2009 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ # This script will delete all of the tweets in a specified account import twitter 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"