Last active
July 16, 2018 08:00
-
-
Save y-gagar1n/0f873da67f0b11f8fdb5bbeaf6b764c0 to your computer and use it in GitHub Desktop.
Revisions
-
y-gagar1n revised this gist
Jul 16, 2018 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ python-twitter -
y-gagar1n created this gist
Jul 15, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ import twitter import config import datetime import time api = twitter.Api(consumer_key=config.CONSUMER_KEY, consumer_secret=config.CONSUMER_SECRET, access_token_key=config.ACCESS_TOKEN_KEY, access_token_secret=config.ACCESS_TOKEN_SECRET, sleep_on_rate_limit=True) delta = datetime.timedelta(days=3*365) earliestDt = datetime.datetime.now() - delta earliest = time.mktime(earliestDt.timetuple()) blacklist = [] friends = api.GetFriendIDs() followers = api.GetFollowers() c = 0 for follower in followers: c = c + 1 print("processing %d of %d" % (c, len(followers))) id = follower.id screen_name = follower.screen_name if not id in friends: try: timeline = api.GetUserTimeline(id, count=1, trim_user=True) if(len(timeline) == 0): blacklist.append((id, screen_name)) else: last_status = timeline[0] created_at = last_status.created_at_in_seconds if(created_at < earliest): blacklist.append((id, screen_name)) except: print("error on %s" % screen_name) blacklist.append((id, screen_name)) for id, name in blacklist: print("blocking " + name) api.CreateBlock(user_id=id)