In [3]:
from TwitterSearch import *
from login import *
import pprint

In [ ]:
try:
    tso = TwitterSearchOrder() # create a TwitterSearchOrder object
    tso.set_keywords(['#picture']) # 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(True) # and give us all those entity information
    tso.arguments.update({'tweet_mode':'extended'}) # get full tweet

    # it's about time to create a TwitterSearch object with our secret tokens
    ts = TwitterSearch(
        consumer_key = CONSUMER_KEY,
        consumer_secret = CONSUMER_SECRET,
        access_token = ACCESS_TOKEN,
        access_token_secret = ACCESS_SECRET
     )

     # this is where the fun actually starts :)
    for tweet in ts.search_tweets_iterable(tso):
        d = {'id': tweet['id'],
                   'urls': not not tweet['entities']['urls'],
                   'media': "media" in tweet["entities"],
                   'text': tweet['full_text']}
        print(d)
        break

except TwitterSearchException as e: # take care of all those ugly errors if there are some
    print(e)
    
print("Done")

In [19]:
try:
    tso = TwitterSearchOrder() # create a TwitterSearchOrder object
    tso.set_keywords(["""You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://go.nasa.gov/2rcqJPC """])
    
    tso.set_language('en') # we want to see German tweets only
    tso.set_include_entities(True) # and give us all those entity information
    tso.arguments.update({'tweet_mode':'extended'})
    
    # it's about time to create a TwitterSearch object with our secret tokens
    ts = TwitterSearch(
        consumer_key = CONSUMER_KEY,
        consumer_secret = CONSUMER_SECRET,
        access_token = ACCESS_TOKEN,
        access_token_secret = ACCESS_SECRET
     )

     # this is where the fun actually starts :)
    for i, tweet in enumerate(ts.search_tweets_iterable(tso)):
        pp = pprint.PrettyPrinter(indent=4)
        print(tweet['full_text'])
        #if i == 10:
         #   break

except TwitterSearchException as e: # take care of all those ugly errors if there are some
    print(e)
    
print("Done")


RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
RT @NASAJPL: You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.…
You Spin Me Round: @NASA_Dawn saw #Ceres at opposition taking imgs from a position between the sun & Ceres’ surface https://t.co/kee7WApuzm https://t.co/tmTAw8rs13
Done

In [ ]: