tweepy 获取失败列表 lookup_users

tweepy get list of failed lookup_users

我想检查一组推特用户是否存在。由于找不到更好的方法,我使用了 api.lookup_users() 但是当找不到用户名时它 returns 什么也没有。如何获取查询失败的用户列表。

>>> api = tweepy.API(auth)
>>> user_ids = api.lookup_users(screen_names['hamid', 'python'])
>>> print user_ids
[19877641]

但我还需要失败的,例如:[19877641,None][19877641,""]

这更多是在 Twitter 方面,而不是 tweepy。如果使用 GET users/lookup 没有找到用户,则不会返回任何内容。所以 tweepy 正在返回从 API.

接收到的内容

来自他们的文档:

There are a few things to note when using this method.

  • You must be following a protected user to be able to see their most recent status update. If you don’t follow a protected user their
    status will be removed.

  • The order of user IDs or screen names may not match the order of users in the returned array.

  • If a requested user is unknown, suspended, or deleted, then that user will not be returned in the results list.

  • If none of your lookup criteria can be satisfied by returning a user object, a HTTP 404 will be thrown.

  • You are strongly encouraged to use a POST for larger requests.

一个可能的解决方法是单独发送用户,如果您收到 None 然后相应地更改您的列表。不幸的是,这可能会阻碍您的限制。