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.destroy_saved_search()
The destroy_saved_search()
method of the API
class in Tweepy module is used to delete a saved search for the authenticated user.
Syntax : API.destroy_saved_search(id)
Parameter :
- id : the ID of the saved search to be destroyed.
Returns : an object of class SavedSearch
Example 1 : Deleting a 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) print ( "The number of saved searches before destroy_saved_search() : " , end = "") print ( len (api.saved_searches())) # query of the saved search id = 1269510986496569349 # deleting the saved search api.destroy_saved_search( id ) print ( "The number of saved searches after destroy_saved_search() : " , end = "") print ( len (api.saved_searches())) |
Output :
The number of saved searches before destroy_saved_search() : 5 The number of saved searches after destroy_saved_search() : 4
Example 2 : Deleting all the saved searches.
# fetching all the saved searhces saved_searches = api.saved_searches() print ( "The number of saved searches before destroy_saved_search() : " , end = "") print ( len (saved_searches)) # deleting all the saved search for saved_search in saved_searches: api.destroy_saved_search(saved_search. id ) print ( "The number of saved searches after destroy_saved_search() : " , end = "") print ( len (api.saved_searches())) |
Output :
The number of saved searches before destroy_saved_search() : 4 The number of saved searches after destroy_saved_search() : 0
<!–
–>
Please Login to comment…