Here's the good news: With a lot of Will's help, I managed to get the code that will spit out any tweet with the code words that I ask for. The code (which is so much simpler than the last one... 24 lines of code instead of 465) looks like this:
from TwitterSearch import *
try:
tso = TwitterSearchOrder() # create a TwitterSearchOrder object
tso.set_keywords(['Trump', 'Hitler']) # let's define all words we would like to have a look for
tso.set_language('en') # we want to see German tweets only
tso.set_include_entities(False) # and don't give us all those entity information
# it's about time to create a TwitterSearch object with our secret tokens
ts = TwitterSearch(
consumer_key = 'E45dKWxNRd4oUQIhNgpSqyncu',
consumer_secret = 'kXV3V69kxXPLUlKq18mOz2eJhDnACVMtx8flkfWM5KG7sMaujy',
access_token = '448004638-yX9qlCQLMIXzNnFm37hiLKhWslWAP1T5ohrj1SDX',
access_token_secret = 'xQ3mGHvPDDVZ0Fke71zrjWWY0eyKHv7GAsSRXqpHD0kYI'
)
# this is where the fun actually starts
for tweet in ts.search_tweets_iterable(tso):
print( '@%s tweeted: %s' % ( tweet['user']['screen_name'], tweet['text'] ) )
except TwitterSearchException as e: # take care of all those ugly errors if there are some
print(e)
And here's the bad news: While it does spit out a list of tweets that look like this:
What I really need is a number of tweets that contain the word "Hitler" and a percentage of those tweets that contain "Trump." I'm looking into an extension called SQLite that might be able to save all of the tweets into a csv file so I can search for a key word. I'll see if it works, or if i can even figure out how to code that.