You can chose to search for only retweets or exclude all retweets from your search query.
For searching for no retweets "-filter:retweets"
for tweet in tweepy.Cursor(api.search, q='github -filter:retweets',tweet_mode='extended').items(5):
For searching for only retweets "filter:retweets"
for tweet in tweepy.Cursor(api.search, q='github filter:retweets',tweet_mode='extended').items(5):
Extra Information:
Whilst you can exclude retweets straight in the search query, it is also very easy to find if a tweet is a retweet because all retweets begin with "rt @UsernameOfAuthor". You can find if a tweet is a retweet by doing a basic if statement to see if the tweet begins with the rt.
first make a basic query and save the information into variables.
for tweet in tweepy.Cursor(api.search, q='github',tweet_mode='extended').items(5):
# Defining Tweets Creators Name
tweettext = str( tweet.full_text.lower().encode('ascii',errors='ignore')) #encoding to get rid of characters that may not be able to be displayed
# Defining Tweets Id
tweetid = tweet.id
Then print the info for demonstration purposes
# printing the text of the tweet
print('tweet text: '+str(tweettext))
# printing the id of the tweet
print('tweet id: '+str(tweetid))
Then there is the if statement to find if it is a retweet or not
# checking if the tweet is a retweet (this method is basic but it will work)
if tweettext.startswith("rt @") == True:
print('This tweet is a retweet')
else:
print('This tweet is not retweet')