Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pprint
- from twython import Twython # pip install twython
- import time
- import collections
- CONSUMER_KEY = ''
- CONSUMER_SECRET = ''
- ACCESS_KEY = ''
- ACCESS_SECRET = ''
- twitter = Twython(CONSUMER_KEY,CONSUMER_SECRET,ACCESS_KEY,ACCESS_SECRET)
- x = twitter.get_followers_ids(screen_name = "") # gets all follower ids
- lis = []
- for ids in x['ids']:
- #print ids
- x = twitter.show_user(user_id = ids) # gets user info
- for k,v in x.iteritems(): # grabs location info
- if k == 'location':
- lis.append(v)
- time.sleep(5)
- else:
- lis.append('no location')
- time.sleep(5)
- counter = collections.Counter(lis)
- for word, value in counter.iteritems():
- print word, value # prints locations and count
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement