Useful links:
Download Python
Download Tweepy
Using Twitter API & Installing Tweepy
Related Topics:
There are three different approaches that could be taken in order to extract the tweets from the users you are either following or simply interested in.

1st option (retrieve_tweets_auto):
  • This approach requires you to follow the users from which you are going to retrieve the tweets
  • The API.friends_ids() method will get the user id from each of the users the specified Twitter account is following
  • The API.get_user() method will get the screen name from each user
I got the original code from this website; however, since the code was written for an older version of Python, I had to modify some parts of the code.

You can download the scripts here
2nd option (retrieve_tweets):
  • This approach does not require you to follow the users from which you are going to retrieve the tweets
The following script simply retrieves the tweets from the users you specify in the "screenNamesList" list.

You can download the scripts here
3rd option (retrieve_tweets_list_ids):
  • This approach does not require you to follow the users from which you are going to retrieve the tweets
The following script simply retrieves the tweets from a list of tweets ids you have previously saved in a text file.

I got the original idea from this website.

You can download the scripts here
The result will be a comma delimited text file which you can export to MS Excel for further analysis.

Read the following information in order to understand the whole process:


Step 1 - Download and install both, Python and Tweepy, and make sure you have a Twitter API. Watch this YouTube video to familiarize yourself with these concepts and the applications.

Step 2 - Download the scripts and place them in a folder.



Step 3 - Run either the "retrieve_tweets_auto", the "retrieve_tweets", or the "retrieve_tweets_list_ids" script. Once you're done, a "data" folder will be created and it will store all the data that was extracted from the tweets. The more users you have, the more times you will have to re-run the script, mainly due to the "time-out" errors.





Step 4 - Open up MS Excel > Click on the "Data" tab > "Get External Data" > "From Text" > Select the "twitDB.txt" file that was generated. Make sure you check the "Delimited" option, use "Unicode (UTF-8)" encoding, and select "Comma" as the delimiter.







web counter
Last Updated: August 15, 2017
© 2011-2017, Luis A. Hernandez
comments powered by Disqus