| 
 | 1 | +# Follower Factory analysis script  | 
 | 2 | + | 
 | 3 | +This Python script was inspired by the New York Times' [Follower Factory article](https://www.nytimes.com/interactive/2018/01/27/technology/social-media-bots.html), which showed that Twitter accounts can be analyzed to discover whether someone has purchased fake followers for that account. This script enables you to analyze any Twitter account and generate a similar scatter plot visualization of their followers. You can typically tell when someone purchased fake followers for an account when there are solid lines of followers that were created around the same time, as shown in the New York Times article.  | 
 | 4 | + | 
 | 5 | +## Dependencies  | 
 | 6 | + | 
 | 7 | +You will need to install Python's [python-twitter](https://github.com/sixohsix/twitter/) library:  | 
 | 8 | + | 
 | 9 | + pip install twitter  | 
 | 10 | + | 
 | 11 | +You will also need to create an app account on https://dev.twitter.com/apps  | 
 | 12 | + | 
 | 13 | +1. Sign in with your Twitter account  | 
 | 14 | +2. Create a new app account  | 
 | 15 | +3. Modify the settings for that app account to allow read & write  | 
 | 16 | +4. Generate a new OAuth token with those permissions  | 
 | 17 | + | 
 | 18 | +Following these steps will create 4 tokens that you will need to place in the script, as discussed below.  | 
 | 19 | + | 
 | 20 | +## Usage  | 
 | 21 | + | 
 | 22 | +Before you can run this script, you need to fill in the following 5 variables in the file:  | 
 | 23 | + | 
 | 24 | +```Python  | 
 | 25 | +USER_TO_ANALYZE = ''  | 
 | 26 | +OAUTH_TOKEN = ''  | 
 | 27 | +OAUTH_SECRET = ''  | 
 | 28 | +CONSUMER_KEY = ''  | 
 | 29 | +CONSUMER_SECRET = ''  | 
 | 30 | +```  | 
 | 31 | + | 
 | 32 | +`USER_TO_ANALYZE` is straightforward: If you want to analyze my Twitter account, you would enter `randal_olson` in between the two single quotes.  | 
 | 33 | + | 
 | 34 | +Once you've created the Twitter app account as described under the Dependencies section, you should be able to find the OAUTH and CONSUMER keys on the "Key and Access Tokens" section, as shown in the image below.  | 
 | 35 | + | 
 | 36 | +<img src='images/twitter-app.example.png' />  | 
 | 37 | + | 
 | 38 | +Once you've filled out those 5 variables, run the script on your command line:  | 
 | 39 | + | 
 | 40 | +```Python  | 
 | 41 | +python follower_factory.py  | 
 | 42 | +```  | 
 | 43 | + | 
 | 44 | +If you're analyzing an account with 100,000s or more of followers, running the script may take a while as the script follows the Twitter API's usage restrictions. A progress bar will keep you updated on the progress of the analysis.  | 
 | 45 | + | 
 | 46 | +Once the script finishes, it will save an image to the directory that you ran the script in. That image will contain the scatter plot visualization for the account you targeted.  | 
 | 47 | + | 
 | 48 | +## Questions and Comments  | 
 | 49 | + | 
 | 50 | +If you have any questions or comments, please [file an issue on this repository](https://github.com/rhiever/Data-Analysis-and-Machine-Learning-Projects/issues/new) and I'll get back to you as soon as I can. If you'd like to submit a pull request to improve this script in any way, please file an issue first to discuss your change(s). I'm generally open to accepting pull requests on this repository.  | 
0 commit comments