Created
November 18, 2022 04:20
-
-
Save justin-pierce/9572ed9e60b7d2c0cffdaf6b3b16d64d to your computer and use it in GitHub Desktop.
Twitter Follows to CSV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import twitter | |
import csv | |
api = None | |
username = "<your_twitter_username>" | |
def authenticate(): | |
global api | |
api = twitter.Api(consumer_key='<consumer_key', | |
consumer_secret='<consumer_secret>', | |
access_token_key='<access_token>', | |
access_token_secret='<access_token_secret>', | |
sleep_on_rate_limit=True) | |
def find_follows(): | |
print("Getting follows") | |
authenticate() | |
follows = api.GetFriends(screen_name=username) | |
print(f"Found {len(follows)} follows") | |
with open('follows.csv', 'w') as csvfile: | |
writer = csv.writer(csvfile) | |
fields = ["Name","Username","url","Bio"] | |
writer.writerow(fields) | |
for follow in follows: | |
writer.writerow([follow.name, follow.screen_name, follow.url, follow.description]) | |
find_follows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment