Commit 21cd3864 authored by Rémy Decoupes's avatar Rémy Decoupes
Browse files

change output format to jsonl : json lines

parent e621a60f
#### Twitter Credentials #### #### Twitter Credentials ####
params/credentials.py params/credentials.py
#### tweets #### #### tweets ####
output/tweetoutput.json output/tweetoutput.jsonl
#### Log #### #### Log ####
log/collectweets.log log/collectweets.log
#### libreoffice back up #### #### libreoffice back up ####
......
...@@ -60,7 +60,7 @@ class Listener(tweepy.StreamListener): ...@@ -60,7 +60,7 @@ class Listener(tweepy.StreamListener):
self.logger.info("initiate stream listener") self.logger.info("initiate stream listener")
def on_status(self, status): def on_status(self, status):
print(status.text, file=self.output_file) print(status._json, file=self.output_file)
def on_error(self, status_code): def on_error(self, status_code):
logger.error("Error on stream twiter: "+str(status_code)) logger.error("Error on stream twiter: "+str(status_code))
...@@ -100,7 +100,7 @@ if __name__ == '__main__': ...@@ -100,7 +100,7 @@ if __name__ == '__main__':
accounttofollowedlist = list(map(str, accounttofollowedlist)) accounttofollowedlist = list(map(str, accounttofollowedlist))
# Start a Twitter stream # Start a Twitter stream
tweetouputfilename = "output/tweetoutput.json" tweetouputfilename = "output/tweetoutput.jsonl"
tweetoutput = open(tweetouputfilename, 'w') tweetoutput = open(tweetouputfilename, 'w')
myStreamListener = Listener(tweetoutput, logger) myStreamListener = Listener(tweetoutput, logger)
stream = tweepy.Stream(auth=api.auth, listener=myStreamListener) stream = tweepy.Stream(auth=api.auth, listener=myStreamListener)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment