Question

I want to write a script that retrieve the tweets from a twitter account. Here is the scenario that I would like to achieve: my script should be able to retrieve all tweets of a user starting from certain date (can be set by the user to any date as long as it's older than current date), until current date.

Example: I want to grab all the tweets of a user from 1st January 2011 until current date (e.g. 10th June 2011)

My question: how to achieve that? I don't need code, I just need the logic or flow of the scenario. Any suggestions or answers are much appreciated. Thank you.

NOTE: The script is written in Python which make use of the python-twitter library to talk to Twitter API. It's also possible to talk directly to the Twitter API without the help of the library if required. This script will be used as a 'desktop application' not web application.

Was it helpful?

Solution

If you're happy with a limit of 3000 statuses you could look at this method. Keep repeating this call to the next page until the first tweet of one of the pages is earlier than the date you're trying to map from.

All you need to do then is iterate through the list while date >= 01/01/2011, and slice it at that point.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top