query_backwards.pyuses the REST API to track a query back as far as possible.track_stream.pyuses the Streaming API.
Run from the command line providing a keyword/query.
$ python3 track_stream.py \#icantbreathe
Developed with Python 3. Probably won't work with Python 2.7 unless backported.
api_key: xxxxxxxxxxxxxxxxxxxxxxxxx
api_secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
token: xxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
token_secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxSometimes the script will grab the same tweet twice. To make sure it doesn't get stored a second time, run this:
$ mongo MY_DB --eval 'db.MY_COLLECTION.ensureIndex( {"id": 1}, {unique: true, dropDups: true} )'
(Obviously replace MY_* with the appropriate values.)
See Create a Unique Index in the MongoDB manual.
Disclaimer: This is a hack and there are likely existing tools that do a better job.