Python – API.get_saved_search() in Tweepy
Last Updated :
10 Jun, 2020
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.
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 tweepy
consumer_key = ""
consumer_secret = ""
access_token = ""
access_token_secret = ""
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
id = 1269503225993900032
saved_search = api.get_saved_search( id )
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 = 1269503225993900032
saved_search = api.get_saved_search( id )
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
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...