Created
May 26, 2017 00:18
-
-
Save romaad/8cccb0bae84f1843ba3580cd976a4c35 to your computer and use it in GitHub Desktop.
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
from __future__ import print_function | |
import twitter | |
#delete tweets that follow a known pattern | |
#requires python-twitter | |
CONSUMER_KEY = 'NOPE' | |
CONSUMER_SECRET = 'NOPE' | |
ACCESS_TOKEN = 'NOPE' | |
ACCESS_TOKEN_SECRET = 'NOPE' | |
#gety your keys following this tutorial : https://python-twitter.readthedocs.io/en/latest/getting_started.html | |
api = twitter.Api(consumer_key=CONSUMER_KEY, | |
consumer_secret=CONSUMER_SECRET, | |
access_token_key=ACCESS_TOKEN, | |
access_token_secret=ACCESS_TOKEN_SECRET) | |
# print(statuses[0].text) | |
global_cnt = 0 | |
start_id = 0 #if it doesn't any matching tweet, try setting this to an older tweet | |
patterns = ["I saved a @YouTube", "I liked a @YouTube", "Answer on @Quora", "My @Quora answer"] | |
while True: | |
cnt = 0 | |
statuses = api.GetUserTimeline(exclude_replies=True, max_id=start_id, count=2000) | |
for status in statuses: | |
for pattern in patterns: | |
if pattern in status.text: | |
st = api.DestroyStatus(status_id= status.id) | |
print("deleted:", st.created_at, st.text) | |
cnt +=1 | |
print ("deleted ",cnt,"tweets") | |
if(cnt == 0): | |
print("finished") | |
break | |
global_cnt += cnt | |
start_id = st.id | |
print ("last_id:",start_id) | |
print("deleted:",global_cnt,"tweet") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment