In this article we will see how we can get the source of a status/tweet. The source of the tweet tells us how the tweet was posted. Some examples of sources are :
In the above mentioned status, the source of the status is : Twitter for Android
We will use the status ID to fetch the status. The status ID of the above mentioned status is 1272771459249844224.
Python3 1==
Output :
We will use the status ID to fetch the status. The status ID of the above mentioned status is 1273112322773581824.
Python3 1==
- Twitter for Android
- Twitter for iPhone
- Twitter Web App
In the above mentioned status, the source of the status is : Twitter for Android
In order to get the source of the status, we have to do the following :Example 1 : Consider the following status :
- Identify the status ID of the status from the GUI.
- Get the Status object of the status using the
get_status()method with the status ID.- From this object, fetch the source attribute present in it.
We will use the status ID to fetch the status. The status ID of the above mentioned status is 1272771459249844224.
# import the module
import tweepy
# assign the values accordingly
consumer_key = ""
consumer_secret = ""
access_token = ""
access_token_secret = ""
# authorization of consumer key and consumer secret
auth = 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 status
id = 1272771459249844224
# fetching the status
status = api.get_status(id)
# fetching the source attribute
source = status.source
print("The source of the status is : " + source)
The source of the status is : Twitter for AndroidExample 2 : Consider the following status :
We will use the status ID to fetch the status. The status ID of the above mentioned status is 1273112322773581824.
# the ID of the status
id = 1273112322773581824
# fetching the status
status = api.get_status(id
# fetching the source attribute
source = status.source
print("The source of the status is : " + source)
Output :
The source of the status is : Twitter Web App