I am recently working on twitter analysis and want to save the results from twitter search locally into .json files.
I am doing both historical search using "searchtweets" and streaming using "tweepy". The result I get are objects which are slightly different but I think both of the results are compatible with .json.
Here are my code(sample, I have a logged in to API already):
new_tweets = API.user_timeline(screen_name='huliangw20', count=20,
tweet_mode='extended')
with open('test_tweets_v2.json', 'w',encoding='utf-8') as outfile:
outfile.write(new_tweets)
It does not work. In general, each query gives me a Resultset of many Tweet objects. And my goal is to save those objects into .json files using python.
Would really appreciate if you could give me some advice on this.