2

I am using the tweepy library in python to search for tweets that contain a certain word. Retrieving all tweets results in a long list, which also includes a lot of retweets. I want to exclude these retweets. The following code works, but now each tweet is processed (also the retweets), which is not ideal considering the rate limit:

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
query = 'test'
max_tweets = 100
for tweet in tweepy.Cursor(api.search, q=query).items(max_tweets):
    jsontweet = json.dumps(tweet._json)
    jsontweet = json.loads(jsontweet)
    if not 'retweeted_status' in jsontweet:
        print(tweet)

Is there a way in which I can specify within my search request to not include retweets? I found that I could include include_rts = False in my code in this post, but I do not know where, and whether it is also working for the API.search function. I was unable to find how to include this parameter in this function in the tweepy documentation.

Community
  • 1
  • 1
Simung
  • 21
  • 2
  • http://stackoverflow.com/questions/29689566/exclude-retweets-from-twitter-streaming-api-using-tweepy looks like this has already been answered – glls May 11 '16 at 13:59
  • The answer to that question results in the same problem: Tweets need to be processed first, before it can be determined whether or not it is a retweet... – Simung May 11 '16 at 14:13

0 Answers0