Created
December 23, 2019 22:00
-
-
Save yasiradn/1d2e16773f9af496d7d9509444f264df to your computer and use it in GitHub Desktop.
Delete all tweets
This file contains 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 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