Skip to content

Instantly share code, notes, and snippets.

@BinaryWasp
Forked from davej/delete_all_tweets.py
Last active August 24, 2021 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BinaryWasp/a296a386e1358c338c2e4b09ec9be02b to your computer and use it in GitHub Desktop.
Save BinaryWasp/a296a386e1358c338c2e4b09ec9be02b to your computer and use it in GitHub Desktop.
This script will delete all of the tweets in a specified account.
# -*- 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 3+, Tweepy (http://pypi.python.org/pypi/tweepy/1.7.1)
"""
import tweepy
CONSUMER_KEY = ''
CONSUMER_SECRET = ''
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):
do_delete = raw_input("> ")
if do_delete.lower() == 'yes':
for status in tweepy.Cursor(api.user_timeline).items():
try:
api.destroy_status(status.id)
api = oauth_login(CONSUMER_KEY, CONSUMER_SECRET)
batch_delete(api)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment