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.
List
The List object in Tweepy module contains the information about a list.
Here are the list of attributes in the List object :
- id : The ID of the list.
- id_str : The ID of the list as a string.
- name : The name of the list.
- uri : The URI of the list.
- subscriber_count : The number of subscribers of the list.
- member_count : The number of members of the list.
- mode : The mode of the list.
- slug : The slug of the list.
- full_name : The full name of the list.
- created_at : The time when the list was created at.
- following : Indicates whether the authenticated user is following the list or not.
- user : The user object of the owner of the list.
Example : Use get_list() method to fetch the list.
Python3
# 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 list list_id = 4343 # fetching the list list = api.get_list(list_id = list_id) # printing the information print ( "The id is : " + str ( list . id )) print ( "The id_str is : " + list .id_str) print ( "The name is : " + list .name) print ( "The uri is : " + list .uri) print ( "The subscriber_count is : " + str ( list .subscriber_count)) print ( "The member_count is : " + str ( list .member_count)) print ( "The mode is : " + list .mode) print ( "The slug is : " + list .slug) print ( "The full_name is : " + list .full_name) print ( "The list was created on : " + str ( list .created_at)) print ( "Is the authenticated user following the list? : " + str ( list .following)) print ( "The screen name of the owner of the list is : " + list .user.screen_name) |
Output :
The id is : 4343 The id_str is : 4343 The name is : Thought Leaders The uri is : /kitson/lists/thought-leaders The subscriber_count is : 4066 The member_count is : 382 The mode is : public The slug is : thought-leaders The full_name is : @kitson/thought-leaders The list was created on : 2009-10-15 23:03:44 Is the authenticated user following the list? : False The screen name of the owner of the list is : kitson