Skip to content

Instantly share code, notes, and snippets.

@dorukcan
Last active February 13, 2016 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dorukcan/c047dab00037782f7890 to your computer and use it in GitHub Desktop.
Save dorukcan/c047dab00037782f7890 to your computer and use it in GitHub Desktop.
followings who write most at recent 1000 tweet
from twython import Twython
def main():
APP_KEY = ""
APP_SECRET = ""
OAUTH_TOKEN = ""
OAUTH_TOKEN_SECRET = ""
twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
my_timeline = twitter.get_home_timeline(count = 200)
my_timeline.extend( twitter.get_home_timeline(count = 200, max_id = my_timeline[len(my_timeline)-1]['id']) )
my_timeline.extend( twitter.get_home_timeline(count = 200, max_id = my_timeline[len(my_timeline)-1]['id']) )
my_timeline.extend( twitter.get_home_timeline(count = 200, max_id = my_timeline[len(my_timeline)-1]['id']) )
my_timeline.extend( twitter.get_home_timeline(count = 200, max_id = my_timeline[len(my_timeline)-1]['id']) )
result = {}
for tweet in my_timeline:
username = tweet['user']['screen_name']
result[username] = result.get(username, 0) + 1
print sorted(result.items(), key=lambda x: x[1], reverse=True)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment