Python – SavedSearch object 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.
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 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 = 1272422627047378944
saved_search = api.get_saved_search( id )
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
Last Updated :
03 Jul, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...