Skip to content

Instantly share code, notes, and snippets.

@yasiradn
Created December 23, 2019 22:00
Show Gist options
  • Save yasiradn/1d2e16773f9af496d7d9509444f264df to your computer and use it in GitHub Desktop.
Save yasiradn/1d2e16773f9af496d7d9509444f264df to your computer and use it in GitHub Desktop.
Delete all tweets
import tweepy
from tweepy import api
# Enter your keys/secrets as strings in the following fields
CONSUMER_KEY = ''
CONSUMER_SECRET = ''
ACCESS_TOKEN = ''
ACCESS_SECRET = ''
deletion_count = 0
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_TOKEN,ACCESS_SECRET)
api = tweepy.API(auth, wait_on_rate_limit=True)
for status in tweepy.Cursor(api.user_timeline).items():
try:
api.destroy_status(status.id)
deletion_count +=1
except:
print ("Failed to delete:", status.id)
print(f'Total Deleted Tweets:{deletion_count}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment