I'm trying to find a URL in a user's profile using Tweepy. At the red circle.
I want to get it as a character string.
If i try to output the URL in the User object, you will get a character string with the link omitted.Corresponding source code
user = api.get_user ("Twitter") print (user.description) #For confirmation print (user.url)
Answer # 1
You can get it normally with the API.
user = api.get_user ("Twitter") url = user.entities ["url"] ["urls"]  ["expanded_url"] print (url)
Answer # 2
When you actually access the shortened URL, you get the expanded URL.
import urllib.request req = urllib.re req = urllib.request.Request ('https://t.co/TAXQpsHa5X', method ='HEAD') resp = urllib.request.urlopen (req) print (resp.url) # https://about.twitter.com/ja.html
requestsYou can also use a library such as.
- i want to get the timeline of multiple users with twitter api
- ruby on rails 5 - i want to display the user's profile image on the post list screen
- Write a Ruby script to deeply mine Twitter users' data
- [python] get twitter profile with tweepy
- how can i change the content of the text that users tweet with twitter's share button in some cases?
- i want to get all users who retweeted using twitter api
- [twitterapi] api for acquiring users who are muting themselves
- i want to get twitter tweets by specifying the user's occupation in python
- postgresql - flask: the query parameter string is garbled
- i want to get a twitter login token
- python - typeerror occurs when removing a url with a regular expression
- python - missing 1 required positional argument error
- api - please tell me how to specify the url parameter (/: xxx) of backlog
- multiple arguments to django