Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tweepy (python): rate limit exceeded code 88

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
like image 304
ytrewq Avatar asked Dec 13 '13 05:12

ytrewq


People also ask

What is wait on rate limit Tweepy?

But keep in mind that Twitter levies a rate limit on the number of requests made to the Twitter API. To be precise, 900 requests/15 minutes are allowed; Twitter feeds anything above that an error.

What is Tweepy in Python?

Tweepy is an open-sourced, easy-to-use Python library for accessing the Twitter API. It gives you an interface to access the API from your Python application. To install the latest version of Tweepy, type the following command in your console: pip install tweepy.

What does Tweepy return?

Returns full Tweet objects for up to 100 Tweets per request, specified by the id parameter.


1 Answers

I put a limit and worked:

def index(request):
    statuses = tweepy.Cursor(api.user_timeline).items(10)
    return TemplateResponse(request, 'index.html', {'statuses': statuses})
like image 165
Alex Garulli Avatar answered Sep 24 '22 08:09

Alex Garulli