X-Git-Url: https://projects.mako.cc/source/twitter-api-cdsw-solutions/blobdiff_plain/1e2d406ccc7bfaa9c73ab809367ce5ae2ab6fc79..d4653b5f599083dc7631ff1a215096ac58b626d8:/solution-followers-2.py diff --git a/solution-followers-2.py b/solution-followers-2.py new file mode 100644 index 0000000..a0a87ef --- /dev/null +++ b/solution-followers-2.py @@ -0,0 +1,23 @@ +# For each of your followers, find out how many followers they have. + +import encoding_fix +import tweepy +from twitter_authentication import CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET +import time + +auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) +auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET) + +api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True) + +user = api.get_user("makoshark") + +for follower in user.followers(): + print("%s : %s" % (follower.screen_name, follower.followers_count)) + + # According to this page, we can make 180 requests for user + # information each 15 minute period or one every 5 seconds: + # + # https://dev.twitter.com/rest/reference/get/users/show + time.sleep(5) +