For this recipe, we are going to use the Twitter API to pull JSON data about Twitter users. Each Twitter user, identified by either a screen name (such as SayHiToSean) or a unique integer, has a profile containing a rich set of information about someone.
The following steps guide you through retrieving a set of Twitter users' profiles:
First, we create a function that will manage pulling twitter profiles:
def pull_users_profiles(ids): users = [] for i in range(0, len(ids), 100): batch = ids[i:i + 100] users += twitter.lookup_user(user_id=batch) print(twitter.get_lastfunction_header('x-rate-limit-remaining')) return (users)
We put this function to use, pulling profiles of both friends and followers:
friends_profiles = pull_users_profiles(friends_ids) followers_profiles = pull_users_profiles(followers_ids)
To check whether...