#-------------------------------------------------------------
# Kevin Fitzgerald - 2018
# 
# Use tweepy to open a stream of tweets and insert those tweets
# into a json file
#-------------------------------------------------------------

import tweepy
from tweepy.streaming import StreamListener
from tweepy import OAuthHandler
from tweepy import Stream

consumer_key = '##########'
consumer_secret = '##########'
access_token = '##########'
access_secret = '##########'

auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_secret)

api = tweepy.API(auth)
 
class MyListener(StreamListener):
 
    def on_data(self, data):
        try:
            with open('pytweets.json', 'a') as f:
                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=['#StanleyCup'])

7d391eb854202a94b7fbb5a8dd5f11de4966b9bd
<mask token>


class MyListener(StreamListener):

    def on_data(self, data):
        try:
            with open('pytweets.json', 'a') as f:
                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


<mask token>

<mask token>
auth.set_access_token(access_token, access_secret)
<mask token>


class MyListener(StreamListener):

    def on_data(self, data):
        try:
            with open('pytweets.json', 'a') as f:
                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


<mask token>
twitter_stream.filter(track=['#StanleyCup'])

<mask token>
consumer_key = '##########'
consumer_secret = '##########'
access_token = '##########'
access_secret = '##########'
auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_secret)
api = tweepy.API(auth)


class MyListener(StreamListener):

    def on_data(self, data):
        try:
            with open('pytweets.json', 'a') as f:
                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=['#StanleyCup'])

import tweepy
from tweepy.streaming import StreamListener
from tweepy import OAuthHandler
from tweepy import Stream
consumer_key = '##########'
consumer_secret = '##########'
access_token = '##########'
access_secret = '##########'
auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_secret)
api = tweepy.API(auth)


class MyListener(StreamListener):

    def on_data(self, data):
        try:
            with open('pytweets.json', 'a') as f:
                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=['#StanleyCup'])

#-------------------------------------------------------------
# Kevin Fitzgerald - 2018
# 
# Use tweepy to open a stream of tweets and insert those tweets
# into a json file
#-------------------------------------------------------------

import tweepy
from tweepy.streaming import StreamListener
from tweepy import OAuthHandler
from tweepy import Stream

consumer_key = '##########'
consumer_secret = '##########'
access_token = '##########'
access_secret = '##########'

auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_secret)

api = tweepy.API(auth)
 
class MyListener(StreamListener):
 
    def on_data(self, data):
        try:
            with open('pytweets.json', 'a') as f:
                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=['#StanleyCup'])
