Guest User

Untitled

a guest
Dec 15th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. class TweetsListener( StreamListener):
  2.  
  3. def __init__(self,path):
  4. self.path = path
  5.  
  6. def on_data(self, data):
  7. try:
  8. s3 = boto3.resource('s3')
  9. s3.put_object(Bucket='bucket',Body=data.encode('UTF-8'),Key='/A/'+self.path+'/test.json)
  10. return True
  11. except BaseException as e:
  12. print("Error on_data: %s" % str(e))
  13. return True
  14.  
  15. def on_error(self, status):
  16. print(status)
  17. return True
Add Comment
Please, Sign In to add comment