Valentin Baltadzhiev
Valentin Baltadzhiev

Reputation: 195

Tweepy not finding results that should be there

I am writing a script in Python, that uses tweepy to search for tweets with a given keyword. Here is the snippet:

for tweet in tweepy.Cursor(api.search, q=keyword, lang="en").items(10):
print tweet.id

I have everything authenticated properly and the code works most of the time. However, when I try to search for some keywords (examples below) it doesn't return anything.

The keywords that cause trouble are "digitalkidz" (a tech conference) and "newtrendbg" (a Bulgarian company). If you do a quick search on Twitter for either of those you will see that there are results. However, tweepy doesn't find anything. Again, it does work for pretty much any other keyword I use.

Do you have any ideas what might be the problem and how to fix it? Thank you

Upvotes: 0

Views: 2089

Answers (1)

Austin A
Austin A

Reputation: 3138

I believe you're forgetting an important aspect of the twitter api, it's not exhaustive.

Taken from the api docs

Please note that Twitter’s search service and, by extension, the Search API is not meant to be an exhaustive source of Tweets. Not all Tweets will be indexed or made available via the search interface.

Regardless of whether you're using the streaming or rest api, you're going to have issues with this if you're looking for specific tweets.


Rest API

When looking for historical tweets, you unfortunately won't be able to obtain anything that is older than a week using api.search(). This is also shown in the docs.

Keep in mind that the search index has a 7-day limit. In other words, no tweets will be found for a date older than one week.

There are other ways of getting older tweets, this post details those options.


Streaming API

While it doesn't sound like you're using twitter's streaming API, it should be noted that this only gives a small sample of twitter's current tweet traffic (~1-2%).

Hopefully this is helpful. Let me know if you have any questions.

Upvotes: 2

Related Questions