如何让所有用户都在列表Twitter API中? [英] How to get all users in a list Twitter API?

查看:156
本文介绍了如何让所有用户都在列表Twitter API中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以访问列表中的所有成员? 目前,我只能看到前20名成员? 具体来说,我正在使用python和tweepy.

Is there a way to access all members in a list? Currently, I can only see the first 20 members? Specifically, I'm using python and tweepy.

推荐答案

在Tweepy中,可以使用Tweepy提供的Cursor类来简化此操作,该类可根据所需的方法调用为返回给您的模型实现适当的迭代器.在您的情况下,您想使用list_members()方法和参数来初始化列表所有者和列表子对象的游标(请参阅https://dev.twitter.com/docs/api/1/get/lists/members ).

In Tweepy, this can be facilitated by using the Cursor class Tweepy provides, which implements an appropriate iterator for the model returned to you depending on your desired method call. In your case, you want to initialize a Cursor with the list_members() method and parameters for the list owner and the list slug (see https://dev.twitter.com/docs/api/1/get/lists/members).

示例(从 http://packages.python.org/tweepy/html/code_snippet.html修改#pagination ):

import tweepy
api = tweepy.API() # Don't forget to use authentication for private lists/users.

# Iterate through all members of the owner's list
for member in tweepy.Cursor(api.list_members, 'list_owner', 'slug').items():
    # Do something with member...

我希望可以链接一些最新文档,但是我唯一能找到的就是这个版本 1.4有关使用游标的文档.仍然建议使用此策略对Tweepy中的Twitter API资源进行分页/迭代结果.

I wish I could link you some up-to-date documentation, but the only thing I can find is this version 1.4 documentation about using Cursors. This strategy is still the recommended way of doing pagination/iteration of results from the Twitter API resources in Tweepy.

这篇关于如何让所有用户都在列表Twitter API中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆