Created
November 19, 2014 21:36
-
-
Save sergiocima/6f8896f7cf17109aeaa1 to your computer and use it in GitHub Desktop.
Convert userid to screename withTwython
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from twython import Twython | |
#Auth steps | |
consumer_key = 'H4JOacuHuJ0RfdUnvsKb6tXge' | |
consumer_secret = 'jh9mLhQKImVG1SViD294pJWDql5cS5aHk2K3Lt7Z2pWeJmewRB' | |
twitter = Twython(consumer_key, consumer_secret) | |
samplefollower = [] | |
#We create a comma separated string from the previous list | |
comma_separated_string = ",".join(samplefollower) | |
print(comma_separated_string) | |
#Now, we query twitter with the comma separated list | |
output = twitter.lookup_user(user_id=comma_separated_string) | |
print(output) | |
username_list=[] | |
#Loop through the results | |
for user in output: | |
username_list.append(user['screen_name']) | |
print('-----------------------------------------------') | |
print(username_list) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment