Tweepy Look up ID with username

时光怂恿深爱的人放手 提交于 2019-12-24 07:36:05

问题


I am trying to get a list of IDs from a list of usernames I have. Is there any method that tweepy provides that lets me do lookup user IDs using their username?


回答1:


Twitter API has the resource https://dev.twitter.com/rest/reference/get/users/lookup for such requirements. It can return user objects for at most 100 users at a time.

You can use this in Tweepy like:

user_objects = api.lookup_users(screen_names=list_of_at_most_100_screen_names)
user_ids = [user.id_str for user in user_objects]


来源:https://stackoverflow.com/questions/42943934/tweepy-look-up-id-with-username

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!