0
Hello, I am improving in Python studies and came across the error: Indexerror: list index out of range
the Code I’m running is this:
import GetOldTweets3 as got
max_tweets = 3
tweets=[]
tweetCriteria = got.manager.TweetCriteria().setUsername("@cbv_jlle").setSince("2019-03-29").setUntil("2019-03-31").setMaxTweets(max_tweets)
for i in range(max_tweets):
tweet = got.manager.TweetManager.getTweets(tweetCriteria)[i]
tweets.append(tweet.text)
print(tweets)
Down with the error:
> IndexError Traceback (most recent call
> last) <ipython-input-85-287bf080b649> in <module>()
> 5 tweetCriteria = got.manager.TweetCriteria().setUsername("@cbv_jlle").setSince("2019-03-01").setUntil("2019-03-02").setMaxTweets(max_tweets)
> 6 for i in range(max_tweets):
> ----> 7 tweet = got.manager.TweetManager.getTweets(tweetCriteria)[i]
> 8 tweets.append(tweet.text)
> 9 print(tweets)
>
> IndexError: list index out of range
Some dates work, others don’t. For example if I change the range to setSince("2019-03-29").setUntil("2019-03-31")
it works.
Sidon, you’ve really improved your performance! But even if I increase my max_tweets to more than 100 (for example), it does not return anything to the setSince range("2019-03-01"). setUntil("2019-03-02"). And from what I saw in the source (Firefighters Joinville @cbv_jlle) there should be 50 tweets in total for the 2 days. Does it have to do with the size of the messages, because there are some messages that are a little more extensive?
– MarciaNakayama
Strange, I did a test here and returns 25 tweets in that period, I’m putting in repl.it, I’ll edit my reply and put the link there.
– Sidon
Ok, the link is already in the answer go there and "play" a little, change the variable number
max_tweets
and the variables determining the periodd1
andd2
.– Sidon
Ball show!!! I didn’t know the repl.it!! Thank you so much for your help!!!
– MarciaNakayama