Last active
April 24, 2020 10:57
-
-
Save smortime/22d896b5d798b6f094e3a38ddfd64227 to your computer and use it in GitHub Desktop.
Script to delete all of your tweets. Requires Python 3.x, Twython, and API keys.
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
#Schuyler Mortimer | |
from twython import Twython | |
import sys | |
#get from twitter developer site | |
APP_KEY = '' | |
APP_SECRET = '' | |
TOKEN = '' | |
TOKEN_SECRET = '' | |
def batch_delete(twitter): | |
#ran into a 200 tweet limit, loop gets around this | |
while True: | |
#get the timeline | |
try: | |
timeline = twitter.get_user_timeline(count=200) | |
except: | |
print("You made a mistake.") | |
sys.exit() | |
if len(timeline) == 0: | |
print("No tweets left to delete") | |
break | |
#delete the timeline | |
for tweet in timeline: | |
status = int(tweet['id_str']) | |
twitter.destroy_status(id=status) | |
print('Tweet deleted: ' + str(status)) | |
print(len(timeline)) | |
def main(): | |
twitter = Twython(APP_KEY, APP_SECRET, TOKEN, TOKEN_SECRET) | |
batch_delete(twitter) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I found this useful!