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.
Media object in Tweepy module contains the information about a media file uploaded on Twitter.
Here are the list of attributes in the Media object :
- media_id : The ID of the media object.
- media_id_str : The ID of the media object as a string.
- size : The size of the media object in bytes.
- expires_after_secs : The time in seconds after which the media object expires.
- image_type : The type of image.
- w : The width of the media object.
- h : The height of the media object.
Example : We will use
media_upload() method to upload and fetch the media object.
Consider the following image :
The media_id is : 1273526215773573121 The media_id_string is : 1273526215773573121 The size is : 3346 The expires_after_secs is : 86400 The image_type is : image/png The w is : 225 The h is : 225
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