Search code examples
pythontweepysamplingtweets

Same date When I try get tweets from tweepy


I'm trying to sample tweets with tweepy. I wanted to get, for example, 100 tweets between today Apr 14th and Apr 8. But when I try:

search_words = "#COVID"
date_until = "2020-04-09"

tweets = twepy.Cursor(api.search,
              q=search_words,
              lang="en",
              until = date_until, count = 100,
                     since = date_since).items(100)

I get the following result with tweets from same day:

2020-04-08 23:58:23    3
2020-04-08 23:59:46    3
2020-04-08 23:58:02    3
2020-04-08 23:59:53    3
2020-04-08 23:58:37    3
2020-04-08 23:58:41    3
2020-04-08 23:59:06    2
2020-04-08 23:59:24    2
2020-04-08 23:59:10    2
2020-04-08 23:59:07    2
2020-04-08 23:58:56    2
2020-04-08 23:59:51    2
2020-04-08 23:58:44    2
2020-04-08 23:58:16    2
2020-04-08 23:59:32    2
2020-04-08 23:57:49    2
2020-04-08 23:57:53    2
2020-04-08 23:58:06    2
2020-04-08 23:59:09    2
2020-04-08 23:59:28    2
2020-04-08 23:58:55    2
2020-04-08 23:59:23    2
2020-04-08 23:59:29    2
2020-04-08 23:57:47    2
2020-04-08 23:59:20    2
2020-04-08 23:59:31    2
2020-04-08 23:57:51    2
2020-04-08 23:58:46    2
2020-04-08 23:58:14    1
2020-04-08 23:59:22    1
2020-04-08 23:58:03    1
2020-04-08 23:58:45    1
2020-04-08 23:59:21    1
2020-04-08 23:59:01    1
2020-04-08 23:58:29    1
2020-04-08 23:59:50    1
2020-04-08 23:59:27    1

Tweets with the same date only differing in some minutes...


Solution

  • add the following in your code

    wait_on_rate_limit – Whether or not to automatically wait for rate limits to replenish

    here is my reference

    api = tweepy.API(auth, wait_on_rate_limit=True)