Python – Status object in Tweepy

03 Jul, 2020
Twitter is a popular social network where users share messages called tweets. Twitter allows us to mine the data of any user using Twitter API or Tweepy. The data will be tweets extracted from the user. The first thing to do is get the consumer key, consumer secret, access key and access secret from twitter developer available easily for each user. These keys will help the API for authentication.
The Status object in Tweepy module contains the information about a status/tweet.
Here are the list of attributes in the Status object :
created_at : The time the status was posted.
id : The ID of the status.
id_str : The ID of the status as a string.
text : The text of the status.
entities : The parsed entities of the status such as hashtags, URLs etc.
source : The source of the status.
source_url : The URL of the source of the status.
in_reply_to_status_id : The ID of the status being replied to.
in_reply_to_status_id_str : The ID of the status being replied to in as a string.
in_reply_to_user_id : The ID of the user being replied to.
in_reply_to_user_id_str : The ID of the user being replied to as a string.
in_reply_to_screen_name : The screen name of the user being replied to
user : The User object of the poster of the status.
geo : The geo object of the status.
coordinates : The coordinates of the status.
place : The place of the status.
contributors : The contributors of the status.
is_quote_status : Indicates whether the status is a quoted status or not.
retweet_count : The number of retweets of the status.
favorite_count : The number of likes of the status.
favorited : Indicates whether the status has been favourited by the authenticated user or not.
retweeted : Indicates whether the status has been retweeted by the authenticated user or not.
possibly_sensitive : Indicates whether the status is sensitive or not.
lang : The language of the status.
Example : Consider the following status :Use get_status() method to fetch the status.
# import the moduleimport tweepy  # assign the values accordinglyconsumer_key = ""consumer_secret = ""access_token = ""access_token_secret = ""  # authorization of consumer key and consumer secretauth = tweepy.OAuthHandler(consumer_key, consumer_secret)  # set access to user's access key and access secret auth.set_access_token(access_token, access_token_secret)  # calling the api api = tweepy.API(auth)  # the ID of the statusid = 1268080321590935553  # fetching the statusstatus = api.get_status(id)  # printing the informationprint("The status was created at : " + str(status.created_at))print("The id is : " + str(status.id))print("The id_str is : " + status.id_str)print("The text is : " + status.text)print("The entitities are : " + str(status.entities))print("The source is : " + status.source)print("The source_url is : " + status.source_url)    print("The in_reply_to_status_id is : " + str(status.in_reply_to_status_id))print("The in_reply_to_status_id_str is : " + str(status.in_reply_to_status_id_str))print("The in_reply_to_user_id is : " + str(status.in_reply_to_user_id))print("The in_reply_to_user_id_str is : " + str(status.in_reply_to_user_id_str))print("The in_reply_to_screen_name is : " + str(status.in_reply_to_screen_name))    print("The poster's screen name is : " + status.user.screen_name)print("The geo is : " + str(status.geo))print("The coordinates are : " + str(status.coordinates))print("The place is : " + str(status.place))print("The contributors are : " + str(status.contributors))print("The is_quote_status is : " + str(status.is_quote_status))print("The retweet_count is : " + str(status.retweet_count))print("The favorite_count is : " + str(status.favorite_count))  print("Has the authenticated user favourited the status? : " + str(status.favorited))print("Has the authenticated user retweeted the status? " + str(status.retweeted))print("Is the status possibly_sensitive? : " + str(status.possibly_sensitive))print("The lang is : " + status.lang)
Output :
The status was created at : 2020-06-03 07:21:23The id is : 1268080321590935553The id_str is : 1268080321590935553The text is : Time really hits differently when you are??holding a plank for a minute,??washing your hands for 20 seconds, and... https://t.co/BBg2RIamGyThe entitities are : {‘hashtags’: [], ‘symbols’: [], ‘user_mentions’: [], ‘urls’: [{‘url’: ‘https://t.co/BBg2RIamGy’, ‘expanded_url’: ‘https://twitter.com/i/web/status/1268080321590935553’, ‘display_url’: ‘twitter.com/i/web/status/1...’, ‘indices’: [116, 139]}]}The source is : Twitter Web AppThe source_url is : https://mobile.twitter.comThe in_reply_to_status_id is : NoneThe in_reply_to_status_id_str is : NoneThe in_reply_to_user_id is : NoneThe in_reply_to_user_id_str is : NoneThe in_reply_to_screen_name is : NoneThe poster’s screen name is : geeksforgeeksThe geo is : NoneThe coordinates are : NoneThe place is : NoneThe contributors are : NoneThe is_quote_status is : FalseThe retweet_count is : 2The favorite_count is : 31Has the authenticated user favourited the status? : TrueHas the authenticated user retweeted the status? FalseIs the status possibly_sensitive? : FalseThe lang is : en
Python-Tweepy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.