Python Tweepy – Getting the source of a tweet
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 :
- Twitter for Android
- Twitter for iPhone
- Twitter Web App
The source attribute of the Status object provides us with the source of the status.
Identifying the source of the status in the GUI :
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 :
- 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.
Example 1 : Consider the following status :
We will use the status ID to fetch the status. The status ID of the above mentioned status is 1272771459249844224.
The source of the status is : Twitter for Android
Example 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 source of the status is : Twitter Web App
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course