-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete_all.py
59 lines (46 loc) · 1.39 KB
/
delete_all.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from deletebot_credentials import twitter_access
import csv
import time
import tweepy
def main():
ckey = twitter_access['consumer_key']
csecret = twitter_access['consumer_secret']
tkey = twitter_access['access_token_key']
tsecret = twitter_access['access_token_secret']
auth = tweepy.OAuthHandler(ckey, csecret)
auth.set_access_token(tkey, tsecret)
api = tweepy.API(auth)
user = api.me()
"""
count = 0
r = 0
with open('tweets.csv', 'rU') as f:
reader = csv.reader(f, delimiter=',', quoting=csv.QUOTE_NONE)
for row in reader:
r += 1
print "Row {}:".format(r)
try:
s = row[0].replace('"', '')
api.destroy_status(s)
count += 1
print "{} destroyed, {} total".format(s, count)
except:
print "whoops!"
"""
"""
# Delete Tweets
count = 0
for page in tweepy.Cursor(api.user_timeline, id=user.id, count=200).pages():
count += len(page)
for tweet in page:
api.destroy_status(tweet.id)
time.sleep(0.1)
print "Deleted {} tweets".format(count)
"""
# 'Destroy' Favorites:
count = 0
for page in tweepy.Cursor(api.favorites, id=user.id, count=200).pages():
count += len(page)
print count
if __name__ == '__main__':
main()