Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tweepy
- from tweepy import OAuthHandler
- import json
- import time
- consumer_key = ''
- consumer_secret = ''
- access_token = ''
- access_secret = ''
- auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
- auth.set_access_token(access_token, access_secret)
- api = tweepy.API(auth)
- with open('tweet_json.txt', 'w') as file:
- for tweet in tweet_ids:
- try:
- tweet_data = api.get_status(tweet, tweet_mode='extended',
- wait_on_rate_limit=True, wait_on_rate_limit_notify=True)
- json.dump(tweet_data._json, file, sort_keys = True, indent=4, ensure_ascii = False) # Add data to the file
- file.write('n') # Add new line after every tweet
- except:
- print("Error: " + str(tweet))
Add Comment
Please, Sign In to add comment