在Tweepy中,可以通过使用Tweepy提供的Cursor类来促进这一点,它根据您所需的方法调用为返回给您的模型实现适当的迭代器.在您的情况下,您希望使用list_members()列表所有者和列表slug 的方法和参数初始化Cursor (请参阅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...
Run Code Online (Sandbox Code Playgroud)
我希望我可以链接到一些最新的文档,但我唯一能找到的是关于使用游标的1.4版文档.这种策略仍然是在Tweepy中对Twitter API资源进行分页/迭代结果的推荐方法.
| 归档时间: |
|
| 查看次数: |
4694 次 |
| 最近记录: |