Created
December 7, 2016 15:32
-
-
Save sw331/2fed6e8c39e42a7c5063ec6aebf44441 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MyListener(StreamListener): | |
| def on_data(self, data): | |
| try: | |
| with open('python0.json', 'a') as f: | |
| tweet = json.loads(data) | |
| if tweet['coordinates']: | |
| print(1) | |
| f.write(data) | |
| return True | |
| except BaseException as e: | |
| print("Error on_data: %s" % str(e)) | |
| return True | |
| def on_error(self, status): | |
| print(status) | |
| return True | |
| twitter_stream = Stream(auth, MyListener()) | |
| twitter_stream.filter(track=['sick']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment