tweepy (python): rate limit exceeded code 88

一曲冷凌霜 提交于 2019-12-01 05:56:31

问题


I'm writing a Twitter application with tweepy that crawls up the tweets by looking at in_reply_to_status_ID. Everything works fine up to the rate limit, after a few minutes, I have to wait another 15 minutes or so.

This is strange because I used nearly identical code until a few months ago before API 1.0 got deprecated, and it didn't have the rate limit problem.

Is there a known way I can get rid of, or at least increase the rate limit? Or is there a workaround?

Seems like a lot of people are having trouble with this, but can't find a definite solution..

i will greatly appreciate it if you could help.

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

回答1:


I put a limit and worked:

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



回答2:


This is due to you reached max limit. Just disconnect your internet connection and reconnect again, no need to wait. Use cursor:

statuses = tweepy.Cursor(api.user_timeline).items(2)

If you get the error again, just reduce items.



来源:https://stackoverflow.com/questions/20559425/tweepy-python-rate-limit-exceeded-code-88

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!