Python Tweepy – Getting the URL of a user
In this article we will see how we can get the URL of a user. The url attribute is a URL provided by the user in association with their profile. The URL attribute is optional and is Nullable.
Identifying the URL in the GUI :
In the above mentioned profile the url is : geeksforgeeks.org
In order to get the URL we have to do the following :
- Identify the user ID or the screen name of the profile.
- Get the User object of the profile using the
get_user()method with the user ID or the screen name.
- From this object, fetch the url attribute present in it.
Example 1: Consider the following profile :
We will use the user ID to fetch the user. The user ID of the above mentioned profile is 57741058.
The URL of the user is : http://t.co/k2iUfxLRBj
Example 2: Consider the following profile :
We will use the screen name to fetch the user. The screen name of the above mentioned profile is PracticeGfG.
The URL of the user is : https://t.co/C5SOw0qMo4
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