2

I am trying to search keywords in twitter through tweepy.

However, I found it seems like that I can not search the tweets one week before, the code below is the main search code.

for searched_tweets in tweepy.Cursor( API.search,
                                      q = "python", 
                                      since = 2014-02-03, 
                                      until = 2014-02-04, 
                                      lang='en' ).items()

I am not sure whether there is any limited or any better way to search by time, thanks for your help!! :)

ThunderSong
  • 23
  • 1
  • 5
  • What's not working about that? What error message(s) are you seeing? – Rowland Shaw Jun 06 '14 at 11:10
  • There is no error message about this code. It can be built, but I can not get any message in this time duration, however, if I change time to 2014-06-03 to 2014-06-04, I can collect all tweets in the new time duration. – ThunderSong Jun 06 '14 at 11:48

1 Answers1

1

Unfortunately, you can't get tweets older than a week with the twitter search API.

Also note that the search results at twitter.com may return historical results while the Search API usually only serves tweets from the past week. - Twitter documentation.

You can get specific tweets older than a week by looking at individual users or using specific post ids (if you have them) but it's not reasonable to index every single tweet ever to be searchable using the API.

If you need a large time range, you can collect them yourself using the streaming API or check out a service that does (see this dev twitter thread for examples).

Luigi
  • 4,129
  • 6
  • 37
  • 57