API.get_saved_search()

The get_saved_search() method of the API class in Tweepy module is used to get a particular saved search.

Syntax : API.get_saved_search(id)

Parameter :

  • id : the ID of the saved search.

Returns : an object of class SavedSearch

Example 1 : Accessing a saved search and printing its query.




# 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)
  
# ID of the saved search
id = 1269503225993900032
  
# 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 query of this saved search is : " + saved_search.query)


Output :

The ID of this saved search is : 1269503225993900032
The query of this saved search is : computer

Example 2 : Print the time of the saved search.




# ID of the saved search
id = 1269503225993900032
  
# fetching the saved search
saved_search = api.get_saved_search(id)
  
# printing the information
print("The saved search " + str(saved_search.id) +
      " was created on : " + str(saved_search.created_at))


Output :

The saved search 1269503225993900032 was created on : 2020-06-07 05:35:29


Python – API.get_saved_search() in Tweepy

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.

Similar Reads

API.get_saved_search()

The get_saved_search() method of the API class in Tweepy module is used to get a particular saved search....