@@ -0,0 +1,1569 @@
+from tweepy.streaming import StreamListener%0Afrom tweepy import OAuthHandler%0Afrom tweepy import Stream%0Aimport json%0Afrom pymongo import MongoClient%0Afrom auth import TwitterOAuth%0A%0Aclass StdOutListener(StreamListener):%0A    %0A    def on_connect(self):%0A        #Called when the connection is made%0A        print(%22You're connected to the streaming server.%22)%0A%09%0A%09#This function gets called every time a new tweet is received on the stream%0A    #Store tweets in 'trumpTweets' collection in 'elections' database%0A    def on_data(self, data):%0A        #print(data)%0A        %0A        client = MongoClient('localhost', 27017)%0A        %0A        # Use 'elections' database%0A        db = client.elections%0A        %0A        # Decode JSON%0A        datajson = json.loads(data)%0A        %0A        # We only want to store tweets in English%0A        if %22lang%22 in datajson and datajson%5B%22lang%22%5D == %22en%22:%0A            # Store tweet info into the 'clintonTweets' collection.%0A            db.trumpTweets.insert(datajson)%0A            #print('Tweet is loaded')%0A            %0A    def on_error(self, status):%0A%09%09print(%22ERROR%22)%0A%09%09print(status)%0A%09%09%0Aif __name__ == '__main__':%0A%09try:%0A        #Create the listener%0A%09%09l = StdOutListener()%0A%09%09auth = OAuthHandler(TwitterOAuth.consumer_key, TwitterOAuth.consumer_secret)%0A%09%09auth.set_access_token(TwitterOAuth.access_token, TwitterOAuth.access_token_secret)%0A%0A%09%09#Connect to the Twitter stream%0A%09%09stream = Stream(auth, l)%09%0A      %0A%09%09#Terms to track%0A%09%09stream.filter(track=%5B%22@realDonaldTrump%22,%22Trump%22,%22Donald Trump%22%5D)%0A%09%09%0A%09except KeyboardInterrupt:%0A%09%09#ctrl+c -%3Eto exit the program%0A%09%09pass%0A

Create trump_streaming.py