tweepy (python):超出速率限制代码 88

ytr*_*ewq 6 python twitter tweepy

我正在用 tweepy 编写一个 Twitter 应用程序,它通过查看 in_reply_to_status_ID 来爬取推文。一切正常,直到速率限制,几分钟后,我必须再等 15 分钟左右。

这很奇怪,因为直到几个月前 API 1.0 被弃用之前我使用了几乎相同的代码,而且它没有速率限制问题。

有没有已知的方法可以摆脱,或者至少提高速率限制?或者有解决方法吗?

似乎很多人都遇到了这个问题,但找不到明确的解决方案..

如果您能提供帮助,我将不胜感激。

auth1 = tweepy.auth.OAuthHandler('consumer_token','consumer_secret')
auth1.set_access_token('access_token','access_secret')
api=tweepy.API(auth1)

def hasParent(s):
    #return true if s is not None, i.e., s is an in_reply_to_status_id numbe 
....

while hasParent(ps):
    try:
        parent=api.get_status(ps)
    except tweepy.error.TweepError:
        print 'tweeperror'
        break
    newparent = parent.in_reply_to_status_id
        ......
    ps=newparent
Run Code Online (Sandbox Code Playgroud)

Ale*_*lli 2

我设置了限制并进行了工作:

def index(request):
    statuses = tweepy.Cursor(api.user_timeline).items(10)
    return TemplateResponse(request, 'index.html', {'statuses': statuses})
Run Code Online (Sandbox Code Playgroud)