【问题标题】:incomplete twitter friend list in python using tweepy使用 tweepy 在 python 中不完整的 Twitter 朋友列表
【发布时间】:2014-08-28 01:32:57
【问题描述】:

我尝试打印我的推特好友列表。我有 112 个朋友,但我只能打印 20 个朋友的网名。是不是因为一些 API 限制/朋友之间的差异和关注/概念错误。这是我的代码:

import tweepy
import sys
import time
consumer_key = ''
consumer_secret = ''
access_token = ''
access_token_secret = ''

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
data = api.get_user('')

count = 0
for friend in data.friends():
        print 'Friend:'+ friend.screen_name
        count=count+1
        if count%5==0:
            print count
        time.sleep(20)

我的解释器没有抛出任何错误。

【问题讨论】:

    标签: python-2.7 tweepy


    【解决方案1】:

    默认情况下,Twitter 每次调用返回 15 条记录。要获得更多:

    • 向 Tweepy 询问更多信息 (count=100) -- doc

    • 使用游标遍历所有数据;见Tutorial

    【讨论】:

      猜你喜欢
      • 2014-11-14
      • 2023-03-03
      • 2015-01-03
      • 1970-01-01
      • 2012-02-12
      • 2012-10-20
      • 1970-01-01
      • 2011-05-18
      • 1970-01-01
      相关资源
      最近更新 更多