Skip to content

Instantly share code, notes, and snippets.

@edsu
Last active June 14, 2016 14:01
Show Gist options
  • Save edsu/1d27faad2ab3351a4c718a1679cf0395 to your computer and use it in GitHub Desktop.
Save edsu/1d27faad2ab3351a4c718a1679cf0395 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
"""
Get user_ids for followers of a particular account:
% ./followers_ids.py jack > ids.txt
"""
import sys
import time
import tweepy
from os import environ as e
if len(sys.argv) != 2:
print "usage: followers_ids.py [screen_name]"
sys.exit(1)
screen_name = sys.argv[1]
auth = tweepy.OAuthHandler(e['CONSUMER_KEY'], e['CONSUMER_SECRET'])
auth.set_access_token(e['ACCESS_TOKEN'], e['ACCESS_TOKEN_SECRET'])
t = tweepy.API(auth, wait_on_rate_limit=True)
c = tweepy.Cursor(
t.followers_ids,
screen_name=screen_name,
count=5000
)
finished = False
while not finished:
try:
for id in c.items():
print id
finished = True
except tweepy.TweepError as e:
sys.stderr.write("caught %s\n" % e)
time.sleep(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment