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.
SavedSearch
The SavedSearch
object in Tweepy module contains the information about a saved search.
Here are the list of attributes in the SavedSearch object :
- id : The ID of the saved search.
- id_str : The ID of the saved search as a string.
- query : The query of the saved search.
- name : The name of the saved search.
- position : The position of the saved search.
- created_at : The time the saved search was created at.
Example : Use get_saved_search()
method to fetch the saved search.
# 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 saved search id = 1272422627047378944 # fetching the saved search saved_search = api.get_saved_search( id ) # printing the information print ( "The id of the saved search is : " + str (saved_search. id )) print ( "The id_str of the saved search is : " + saved_search.id_str) print ( "The query of the saved search is : " + saved_search.query) print ( "The name of the saved search is : " + saved_search.name) print ( "The position of the saved search is : " + str (saved_search.position)) print ( "The saved search was created at : " + str (saved_search.created_at)) |
Output :
The id of the saved search is : 1272422627047378944 The id_str of the saved search is : 1272422627047378944 The query of the saved search is : Tweepy The name of the saved search is : Tweepy The position of the saved search is : None The saved search was created at : 2020-06-15 06:56:09
<!–
–>
Please Login to comment…