json - accessing multiple twitter user profiles in python -


so trying access twitter's api user specific profile information list of user id's have. following code seems work , able json data output. question if can several users(several 1000's) , if how them in table format?

here code resulting output 1 user

def get_user_profile(twitter_api, screen_names=none, user_ids=none):      # must have either screen_name or user_id (logical xor)     assert (screen_names != none) != (user_ids != none), \     "must have screen_names or user_ids, not both"      items_to_info = {}      items = screen_names or user_ids      while len(items) > 0:          # process 100 items @ time per api specifications /users/lookup.         # see https://dev.twitter.com/docs/api/1.1/get/users/lookup details.          items_str = ','.join([str(item) item in items[:100]])         items = items[100:]          if screen_names:             response = make_twitter_request(twitter_api.users.lookup,                                              screen_name=items_str)         else: # user_ids             response = make_twitter_request(twitter_api.users.lookup,                                              user_id=items_str)          user_info in response:             if screen_names:                 items_to_info[user_info['screen_name']] = user_info             else: # user_ids                 items_to_info[user_info['id']] = user_info      return items_to_info  response = get_user_profile(twitter_api, screen_names=["juniorsantanab1"])  print json.dumps(response, indent=1) 

output:

{  "juniorsantanab1": {   "follow_request_sent": false,    "profile_use_background_image": true,    "default_profile_image": true,    "id": 2565811553,    "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png",    "verified": false,    "profile_text_color": "333333",    "profile_image_url_https": "https://abs.twimg.com/sticky/default_profile_images/default_profile_4_normal.png",    "profile_sidebar_fill_color": "ddeef6",    "entities": {    "description": {.......etc 


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -