dekaottoman
dekaottoman

Reputation: 63

Collecting old tweets between a specific time period

I am trying to collect tweets using tweepy. The resources I have checked all use the parameters since and until which has not worked so far. I also tried twint and GetOldTweets3 to no success.

The search I tried on tweepy:

tweets = tw.Cursor(api.search_tweets,q=search_query,lang="en", since="2020-03-01", until="2020-03-01").items(1000)

Is there a way to collect tweets between the specified time period or will I need to use another API? And if I need to use another API could you please elaborate on how it should be used?

Upvotes: 0

Views: 917

Answers (2)

Marina
Marina

Reputation: 11

Try to include the time period in the search query.

search_query = 'tesla since:2020-03-01 until:2020-03-01'

tweets = tw.Cursor(api.search_tweets,q=search_query,lang="en")

Upvotes: 1

Mickaël Martinez
Mickaël Martinez

Reputation: 1843

From the Tweepy documentation of the search_tweets method (here):

Twitter’s standard search API only “searches against a sampling of recent Tweets published in the past 7 days".

If you’re specifying an ID range beyond the past 7 days or there are no results from the past 7 days, then no results will be returned.

See Twitter’s documentation on the standard search API for more information.

If you need to retrieve tweets from 2020, you would have either to pay for the premium access in the V1.1 API or to apply for an academic access in the V2.

There is no other way to do that with the official Twitter API.

Upvotes: 0

Related Questions