I am using the twitter api to retrieve tweets by ID.I have 13 ids. However tweets of only 8 ids are displayed. (There is no error though). The code is as follows
from tweepy import OAuthHandler
import tweepy
import TwitterCredentials
def status_lookup(api, filename):
id_list = [591672103788621824, 591673483832270848,91675312032776192,591677980394393600, 591678618935267328, 591679831399477248, 591681597054652416, 591681654047023104,591681941017100288, 591693321111744513,591712699421052928, 591712700138291201, 591714830446301184]
tweets = api.statuses_lookup(id_list)
# tweets = []
# tweets.extend(api.statuses_lookup(ids))
a = len(tweets)
print(a)
try:
for tweet in tweets:
print("New Tweet : ", tweet.text)
with open(filename, 'a', encoding="utf-8") as tf:
for tweet in tweets:
tf.write("New Tweet:" + ":" + tweet.text + "\n")
return True
except BaseException as e:
print("Error on_data %s" % str(e))
return True
if __name__ == '__main__':
# print(len(id_list))
fetched_tweets_filename = "Rtweets.txt"
auth=OAuthHandler(TwitterCredentials.CONSUMER_KEY,TwitterCredentials.CONSUMER_SECRET)
auth.set_access_token(TwitterCredentials.ACCESS_TOKEN,TwitterCredentials.ACCESS_TOKEN_SECRET)
api = tweepy.API(auth)
status_lookup(api, fetched_tweets_filename)
I am clueless! Please help!
The list of IDs passed to that method allows for up to 100 Tweet IDs.
I just checked this and it looks like for the five IDs not returned, the user accounts have been suspended and the Tweets are no longer available.