[Tutor] how to only loop over first 'x' items of a list; writing a Twitter bot with tweepy
Jared Nielsen
jared at thehelloworldprogram.com
Mon Nov 25 19:18:17 CET 2013
Hi all,
Noob. For a beginner project I'm hacking together a Twitter bot with tweepy.
I've got one more or less functional, but I'm running into a problem when
making a list of followers by calling the Twitter api. I'm getting a 'Rate
limit exceeded' error, which, evidently is due to changes in the Twitter
api not allowing one to make more than a certain number of calls. I think
150 at a time. I have more than 150 followers in the account.
My code is:
for follower in tweepy.Cursor(api.followers).items():
follower_ids.append(follower.id)
My question is: how do I grab the first 'x' items in
tweepy.Cursor(api.followers)items(), say 15 or 20, without looping through
the entire list of items, which then gives me the error.
Thanks!
--
http://thehelloworldprogram.com
http://dototot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20131125/628e3dc8/attachment.html>
More information about the Tutor
mailing list