最新版本的 Twitter api 是否删除了通过一次调用检索多个用户对象的功能?
如果不是的话,还是GetUser函数吗?
如果我有用户屏幕名称列表,如何通过一次调用检索所有用户对象?
例如如果列表是: 用户 = [用户1,用户2,用户3......用户200]
开发者手册可能有答案,但我正在努力找出答案。
最佳答案
用户查找没有为您提供所需的信息吗?
GET users/lookup
引用:https://dev.twitter.com/docs/api/1/get/users/lookup
Return up to 100 users worth of extended information, specified by either ID, screen name, or combination of the two. The author's most recent status (if the authenticating user has permission) will be returned inline.
This method is crucial for consumers of the Streaming API. It's also well suited for use in tandem with friends/ids and followers/ids.
在 python-twitter ,可通过以下方式访问:
def UsersLookup(self, user_id=None, screen_name=None, users=None):
来源:https://github.com/bear/python-twitter/blob/master/twitter.py#L3189
Fetch extended information for the specified users.
Users may be specified either as lists of either user_ids, screen_names, or twitter.User objects. The list of users that are queried is the union of all specified parameters.
The twitter.Api instance must be authenticated.
Args: user_id: A list of user_ids to retrieve extended information. [Optional] screen_name: A list of screen_names to retrieve extended information. [Optional] users: A list of twitter.User objects to retrieve extended information. [Optional]
Returns: A list of twitter.User objects for the requested users
这是“tweepy”的一些信息
""" Perform bulk look up of users from user ID or screenname """
def lookup_users(self, user_ids=None, screen_names=None):
https://github.com/tweepy/tweepy/blob/master/tweepy/api.py#L146
关于python - 使用最新的 twitter api 和 python 检索多个用户对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15485457/