Skip to content

Instantly share code, notes, and snippets.

@justin-pierce
Created November 18, 2022 04:20
Show Gist options
  • Save justin-pierce/9572ed9e60b7d2c0cffdaf6b3b16d64d to your computer and use it in GitHub Desktop.
Save justin-pierce/9572ed9e60b7d2c0cffdaf6b3b16d64d to your computer and use it in GitHub Desktop.
Twitter Follows to CSV
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