how do I derrive a plaintext username from a user Id number with tweepy?
Here is the CORRECTED code that I am using:
ids = []
userid = "someOne"
for page in tweepy.Cursor(api.followers_ids, screen_name=userid).pages():
ids.extend(page)
time.sleep(60)
print len(ids), "following have been gathered from", userid
users = api.lookup_users(user_ids=ids)#ieterates through the list of users and prints them
for u in users:
print u.screen_name
The last line I have commented is the one giving me an issue. Please advise. Thank you all!
You are iterating ids
and i
already contains element of ids
. Try to pass i
to lookup_users
:
for i in ids:
print screen_name(api.lookup_users(i))
# print screen_name(api.lookup_users(ids[i]))
update, try this way:
users = api.lookup_users(user_ids=ids)
for u in users:
print u.screen_name
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With