I am trying to use the code I share below to fetch the user data and tweets.
def get_all_tweets(screen_name):
api = tweepy.API(auth)
#initialize a list to hold all the tweepy Tweets
alltweets = []
#make initial request for most recent tweets (200 is the maximum allowed count)
new_tweets = api.user_timeline(screen_name = screen_name,count=200)
#save most recent tweets
alltweets.extend(new_tweets)
#save the id of the oldest tweet less one
oldest = alltweets[-1]["id"] - 1
Everything seems to be set up well, but when I run the code, I get this error:
<ipython-input-7-2ce84a05eaae> in get_all_tweets(screen_name)
110
111 #save the id of the oldest tweet less one
--> 112 oldest = alltweets[-1]["id"] - 1
113
114
TypeError: 'Status' object is not subscriptable
Why is 'Status' non-subscriptable? And is there a way I can fix this issue?
Someone please help me!
Statusobjects aren't subscriptable. The code must access their attributes via the dot operator: