A project written in Python to get old tweets, it bypass some limitations of Twitter Official API.
Twitter Official API has the bother limitation of time constraints, you can't get older tweets than a week. Some tools provide access to older tweets but in the most of them you have to spend some money before. I was searching other tools to do this job but I didn't found it, so after analyze how Twitter Search through browser works I understand its flow. Basically when you enter on Twitter page a scroll loader starts, if you scroll down you start to get more and more tweets, all through calls to a JSON provider. After mimic we get the best advantage of Twitter Search on browsers, it can search the deepest oldest tweets.
This package assumes using Python 2.x. The Python3 "got3" folder is maintained as experimental and is not officially supported.
Expected package dependencies are listed in the "requirements.txt" file for PIP, you need to run the following command to get dependencies:
pip install -r requirements.txt
Tweet: Model class to give some informations about a specific tweet.
TweetManager: A manager class to help getting tweets in Tweet's model.
TwitterCriteria: A collection of search parameters to be used together with TweetManager.
Main: Examples of how to use.
Exporter: Export tweets to a csv file named "output_got.csv".
Get tweets by username
tweetCriteria = got.manager.TweetCriteria().setUsername('barackobama').setMaxTweets(1)
tweet = got.manager.TweetManager.getTweets(tweetCriteria)[0]
print tweet.text
Get tweets by query search
tweetCriteria = got.manager.TweetCriteria().setQuerySearch('europe refugees').setSince("2015-05-01").setUntil("2015-09-30").setMaxTweets(1)
tweet = got.manager.TweetManager.getTweets(tweetCriteria)[0]
print tweet.text
Get tweets by username and bound dates
tweetCriteria = got.manager.TweetCriteria().setUsername("barackobama").setSince("2015-09-10").setUntil("2015-09-12").setMaxTweets(1)
tweet = got.manager.TweetManager.getTweets(tweetCriteria)[0]
print tweet.text
Get the last 10 top tweets by username
tweetCriteria = got.manager.TweetCriteria().setUsername("barackobama").setTopTweets(True).setMaxTweets(10)
# first one
tweet = got.manager.TweetManager.getTweets(tweetCriteria)[0]
print tweet.text
python Exporter.py -h
python Exporter.py --username "barackobama" --maxtweets 1
python Exporter.py --querysearch "europe refugees" --maxtweets 1
python Exporter.py --username "barackobama" --since 2015-09-10 --until 2015-09-12 --maxtweets 1
python Exporter.py --username "barackobama" --maxtweets 10 --toptweets