Advertisement
slipcell

follower locations

Mar 30th, 2014
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. import pprint
  2. from twython import Twython # pip install twython
  3. import time
  4. import collections
  5.  
  6. CONSUMER_KEY = ''
  7. CONSUMER_SECRET = ''
  8. ACCESS_KEY = ''
  9. ACCESS_SECRET = ''
  10.  
  11. twitter = Twython(CONSUMER_KEY,CONSUMER_SECRET,ACCESS_KEY,ACCESS_SECRET)
  12.  
  13. x = twitter.get_followers_ids(screen_name = "") # gets all follower ids
  14.  
  15. lis = []
  16. for ids in x['ids']:
  17.     #print ids
  18.     x = twitter.show_user(user_id = ids) # gets user info
  19.     for k,v in x.iteritems(): # grabs location info
  20.         if k == 'location':
  21.             lis.append(v)
  22.             time.sleep(5)
  23.         else:
  24.             lis.append('no location')
  25.             time.sleep(5)
  26.  
  27. counter = collections.Counter(lis)
  28. for word, value in counter.iteritems():
  29.     print word, value # prints locations and count
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement