i'm working on the a udacity project wrangling data trying to gather tweets data like retweets and likes counts but this code only prints 'fail'
consumer_key = 'MYKEY'
consumer_secret = 'MYKEY'
access_token = 'MYKEY'
access_secret = 'MYKEY'
auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_secret)
api = tweepy.API(auth, wait_on_rate_limit=True)
tweet_ids = archive.tweet_id.values
count = 0
fails_dict = {}
start = timer()
#Save each tweet's returned JSON as a new line in a .txt file
with open('tweet_json.txt', 'w') as outfile:
# This loop will likely take 20-30 minutes to run because of Twitter's rate limit
for tweet_id in tweet_ids:
count += 1
print(str(count) + ": " + str(tweet_id))
try:
tweet = api.get_status(tweet_id, tweet_mode='extended')
print("Success")
json.dump(tweet._json, outfile)
outfile.write('\n')
except Exception as e:
print("Fail")
fails_dict[tweet_id] = e
pass
end = timer()
print(end - start)
print(fails_dict)
i've been struggling to gather these data tried different code but i find the data frame empty at the end if its something has to be done with my Twitter Developers account please tell me
i tried different code expecting tweet data to be stored in the df