Created
April 24, 2020 21:56
-
-
Save sukruozan/a5864d337bf64ee07c57578f80ca6ea8 to your computer and use it in GitHub Desktop.
This script allows you to delete all the tweets in a twitter account using twython library. You have to first download the twitter history archive and then extract the downloaded folder. All the information regarding the tweets can be found in "tweet.js" file. This file can easly be read and manipulated using python.
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 re | |
from twython import Twython | |
import sys | |
# authorization info of your app | |
auth = {'APP_KEY':'', | |
'APP_SECRET':'', | |
'OAUTH_TOKEN':'', | |
'OAUTH_TOKEN_SECRET':'', | |
'SCREEN_NAME':'', | |
'keywords':[], | |
'users':['']} | |
#get from twitter developer site | |
APP_KEY = auth['APP_KEY'] | |
APP_SECRET = auth['APP_SECRET'] | |
TOKEN = auth['OAUTH_TOKEN'] | |
TOKEN_SECRET = auth['OAUTH_TOKEN_SECRET'] | |
# instance creation | |
twitter = Twython(APP_KEY, APP_SECRET, TOKEN, TOKEN_SECRET) | |
# tweet.js file should be in the same path of this script | |
id_list = [] | |
for line in open("tweet.js", "r").readlines(): | |
if '"id"' in str(line): | |
tmp = str(line).replace('"id" : ','') | |
id_list.append(re.findall('"([^"]*)"', tmp)[0]) | |
for id in id_list: | |
try: | |
twitter.destroy_status(id=id) | |
except: | |
None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment