Reputation: 95
This is my code:
searched_tweets = []
new_tweets = api.search(q=query, count=remaining_tweets, since_id=str(since_id), max_id=str(max_id))
searched_tweets.append(new_tweets)
def write_tweets(tweets, filename):
with open(filename + ".json", "w") as f:
for tweet in tweets:
json.dump(tweet, f)
f.write('\n')
write_tweets(searched_tweets, "testfile")
And I get this error when I try to write tweets to a new json file.
AttributeError: 'SearchResults' object has no attribute '_json'
I'm using Python 3x.
Upvotes: 0
Views: 143
Reputation: 599956
You're appending the search result as a whole to the searched_tweets list, so that now consists of a single item.
You should remove the searched_tweets stuff altogether and just pass new_tweets to your function.
Upvotes: 1