<jupyter_start><jupyter_text>For real time streaming of accounts. ONLY RUN<jupyter_code>import tweepy 
import json

#Importing twitter credentials
# from twitter_credentials import *
#Accesing twitter from the App created in my account
def autorize_twitter_api():
    consumer_key = "jzn0NU9EviCRRbONbUXX9a8VN"
    consumer_secret = "<KEY>"
    access_token = "<KEY>"
    access_token_secret = "<KEY>"
    auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
    auth.set_access_token(access_token, access_token_secret)
    
    return auth
class MyStreamListener(tweepy.StreamListener):
    
    """
    def on_status(self, status):
        print(status.text)
    """
    def __init__(self, filename, api=None):
        self.filename = filename
    
        tweepy.StreamListener.__init__(self, api=api)

        
    def on_data(self, raw_data):

        try:
            with open(self.filename, 'a') as file:
                file.write(raw_data)
  
            
        except Exception as e:
            print(e)
    
    def on_error(self, status_code):
        if status_code == 420:
            #returning False in on_error disconnects the stream
            return False
# For realtime streaming
if __name__ == "__main__": 
    #Creates the table for storing the tweets
    term_to_search = input("Enter hashtag to see live results: ")
    
    #Connect to the streaming twitter API
    api = tweepy.API(wait_on_rate_limit_notify=True)
    
    #Stream the tweets
    streamer = tweepy.Stream(auth=autorize_twitter_api(), listener=MyStreamListener(api=api, filename='tweets.txt'))
    streamer.filter(languages=["en"], track=[term_to_search])   
    myStream.disconnect()<jupyter_output>Enter hashtag to see live results: iowastate
{'fraction_non_alphanumeric': 0.08767908309455587, 'fraction_numerical': 0.0040114613180515755, 'mean_word_length': 3.137440758293839, 'pattern_counts': {'":': 1, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '296970', 'license': 'MIT', 'n_tokens_mistral': 560, 'n_tokens_neox': 541, 'n_words': 131, 'path': 'Part_2_User_Input_Twitter_Analysis/User Input Hashtag Live Stream-Tweet.ipynb', 'repo_name': 'ChHarding/Twitter-Project', 'size': '1875'}