Missing attributes and entities


I’m using the Python dictionary below in my twitter search and encounter 2 issues:

  1. AttributeError indicating missing attributes. When I removed them from the dictionary I was able to run the script.
  2. But then I found that I don’t get the entities.
    I get all other attributes accurately. Also, these issues do not come-up when I’m filtering Streaming API. There I get all the attributes including entities.

Any idea about how to get all attributes in the Rest API as well?


def tweet_to_dict(tweet):
    ''' Function that returns dictionary based on tweets' dictionaries. '''
    tweet_dict = {
        "Date-Time": tweet.created_at,
        "Author name": tweet.user.screen_name,
        "Author followers": tweet.user.followers_count,        
        "Text": tweet.text,
        "Language": tweet.lang,
        "Author location": tweet.user.location,
        "Tweet Location-Geo":tweet.geo,
        "Tweet location": tweet.coordinates,
        "Place associated with":tweet.place,
        "Replying to user": tweet.in_reply_to_screen_name,
        "Replying to message (ID)": tweet.in_reply_to_status_id,
        "Contains another tweet": tweet.is_quote_status,       
        "Likes": tweet.favorite_count,
        "Retweets": tweet.retweet_count,
        "Tweet ID": tweet.id,
        "User replied to-ID": tweet.in_reply_to_user_id,
        "User_json": tweet.user,
    return tweet_dict

#attributes removed due to AttributeError (tweets lacking these attributes): 
#"A quoted tweet?": tweet.quoted_status
#"Quotes": tweet.quote_count,
#"Replies": tweet.reply_count,
#"Flagged as sensitive":tweet.possibly_sensitive,
#"Tweet quoted-ID": tweet.quoted_status_id,
#"Timestamp": tweet.Timestamp_ms