<jupyter_start><jupyter_text>A00279668 File for downloading the training set  This script downloads tweets using tweepy<jupyter_code>import tweepy
from tweepy import OAuthHandler
import pandas as pd
consumer_key = input("Paste your consumer key here: ")
consumer_secret = input("Paste your consumer secret here: ")
access_token = input("Paste your access token here: ")
access_token_secret = input("Paste your access token secret here: ")
num_tweets = int(input("Enter the number of tweets you want to download: "))
search = input("Enter the topic of your search: ")
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)

api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True)

tweets = []

search = 'RightRoyalMess' 

count = 1

for tweet in tweepy.Cursor(api.search, q='( search AND -filter:replies AND -filter:retweets',
                           count=450,
                           lang="en",
                           ).items(num_tweets):

    count += 1

    try: 
        data = [tweet.created_at, tweet.id, tweet.text,
                tweet.user._json['screen_name'],
                tweet.user._json['name'],
                tweet.user._json['created_at'],
                tweet.entities['urls']]
        data = tuple(data)
        tweets.append(data)
        
    except tweepy.TweepError as e:
        print(e.reason)
        continue

    except StopIteration:
        break

print("Tweets extracted")
        
df = pd.DataFrame(tweets, columns = ['created_at','tweet_id', 'tweet_text', 'screen_name',
                                     'name', 'account_creation_date', 'urls'])
fileout = input("Enter a filename: ")
fileout = fileout +'.csv'
df.to_csv(fileout, index=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10730088495575221, 'fraction_numerical': 0.007190265486725664, 'mean_word_length': 2.9326086956521737, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '584776', 'license': 'Apache-2.0', 'n_tokens_mistral': 584, 'n_tokens_neox': 554, 'n_words': 134, 'path': 'Code/Tweepy/Tweet download bot.ipynb', 'repo_name': 'SimonMcLain/TUS-Engineering-Team-Project', 'size': '1808'}