This is a containerized version of tweets_analyzer.
First: visit https://apps.twitter.com/ to generate some Twitter API keys.
Export your API keys as shell variables like so:
export TWEETSANALYSER_CONSUMER_KEY='xxxxxxxxxxxxxxx'
export TWEETSANALYSER_CONSUMER_SECRET='xxxxxxxxxxxxxxx'
export TWEETSANALYSER_ACCESS_TOKEN='xxxxxxxxxx-xxxxxxxxxxxxxxx'
export TWEETSANALYSER_TOKEN_SECRET='xxxxxxxxxxxxxxx'
Now you can run this container with (where username
is the user you wish to analyze):
docker run --rm -it -e consumer_key="$TWEETSANALYSER_CONSUMER_KEY" -e consumer_secret="$TWEETSANALYSER_CONSUMER_SECRET" -e access_token="$TWEETSANALYSER_ACCESS_TOKEN" -e token_secret="$TWEETSANALYSER_TOKEN_SECRET" registry.gitlab.com/alexhaydock/tweets_analyzer username
Alternatively, you can place your API keys directly into the docker run
command, or store them in a docker-compose.yml
file.
The goal of this simple python script is to analyze a Twitter profile through its tweets by detecting:
- Average tweet activity, by hour and by day of the week
- Timezone and language set for the Twitter interface
- Sources used (mobile application, web browser, ...)
- Geolocations
- Most used hashtags, most retweeted users and most mentioned users
- Friends analysis based on most frequent timezones/languages
There are plenty of things that could be added to the script, feel free to contribute! 👍
⚠ First, update your API keys in the secrets.py file. To get API keys go to https://apps.twitter.com/
Python v2.7 or newer is required
You will need the following python packages installed: tweepy, ascii_graph, tqdm, numpy
If you have pipenv installed you can just run:
$ pipenv install
Otherwise you can use:
$ pip install -r requirements.txt
usage: tweets_analyzer.py -n <screen_name> [options]
Simple Twitter Profile Analyzer
optional arguments:
-h, --help show this help message and exit
-l N, --limit N limit the number of tweets to retreive (default=1000)
-n screen_name, --name screen_name
target screen_name
-f FILTER, --filter FILTER
filter by source (ex. -f android will get android
tweets only)
--no-timezone removes the timezone auto-adjustment (default is UTC)
--utc-offset UTC_OFFSET
manually apply a timezone offset (in seconds)
--friends will perform quick friends analysis based on lang and
timezone (rate limit = 15 requests)
-e path/to/file, --export path/to/file
exports results to file
-j, --json outputs json
-s, --save saves tweets to tweets/{twitter_handle}/{yyyy-mm-
dd_HH-MM-SS}.json
--no-color disables colored output
--no-retweets does not evaluate retweets
GNU GPLv3
If this tool has been useful for you, feel free to thank me by buying me a coffee