How to Get Tweets Older Than a Week (Using Tweepy or Other Python Libraries)

Tweepy api.search, how to get the tweets older than 10 days?

You can't. The Twitter Search API searches against a sampling of recent Tweets published in the past 7 days.

Tweepy: get old tweets now possible with Twitter search api?

Unfortunately, you cannot access past data from Twitter. Is not a problem of what library you're using: Tweepy, Twitter4J, whatever, is just that Twitter won't provide any data that is older than more or less 2 weeks.

To get historical data you'll need access to firehose, directly through Twitter or third-party resellers like GNIP.

How to retrieve tweets from a week ago using Tweepy in API 3.9

The Twitter API itself does not support an even distribution of results on a per-day basis across a week, so you would have to implement this yourself. The count parameter only supports a maximum of 100 results per page. At the moment, your code is basically asking for 100 Tweets looking back from now.

You could try the following:

  • break down your 1000 results by 7 days (to make this easier, let's make it 100 per day, so 700 Tweets total)
  • create a 7 pass loop around your second block of code, and for each iteration, search for 100 results, each time making the since and until values for the same day, so '2020-11-12' to '2020-11-12', '2020-11-13' to '2020-11-13', etc
  • in each loop iteration, append your data into the dataframe

Also note that the line where you have term = 'Panamá' is apparently unused in the code above.



Related Topics



Leave a reply



Submit