Skip to content

Commit 5aee5b7

Browse files
committed
Upload usage instructions for Follower Factory script
1 parent 247089b commit 5aee5b7

File tree

3 files changed

+51
-2
lines changed

3 files changed

+51
-2
lines changed

follower-factory/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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.

follower-factory/follower_factory.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@
3333
CONSUMER_KEY = ''
3434
CONSUMER_SECRET = ''
3535

36-
twitter_connection = Twitter(auth=OAuth(OAUTH_TOKEN, OAUTH_SECRET,
37-
CONSUMER_KEY, CONSUMER_SECRET))
36+
twitter_connection = Twitter(auth=OAuth(OAUTH_TOKEN, OAUTH_SECRET, CONSUMER_KEY, CONSUMER_SECRET))
3837

3938
pbar = tqdm()
4039
pbar.write('Collecting list of Twitter followers for @{}'.format(USER_TO_ANALYZE))
97 KB
Loading

0 commit comments

Comments
 (0)