Skip to content

Instantly share code, notes, and snippets.

@jbn
Created March 6, 2020 21:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbn/f287fd5d173a14469e361611837130bd to your computer and use it in GitHub Desktop.
Save jbn/f287fd5d173a14469e361611837130bd to your computer and use it in GitHub Desktop.
import tweepy # pip install tweepy
import json
import time
from missing_builtins import chunker # pip install missingbuiltins
with open("twitter_creds.json") as fp: # Yours with the fields below
creds = json.load(fp)
auth = tweepy.OAuthHandler(creds['appKey'], creds['appSecret'])
auth.set_access_token(creds['userToken'], creds['userSecret'])
api = tweepy.API(auth)
follower_ids = set(tweepy.Cursor(api.followers_ids, count=5000).items())
followers = {}
for i, chunk in enumerate(chunker(follower_ids, 100)):
print(f"Group: {i}")
for user in api.lookup_users(chunk):
followers[user.id] = user
for user in followers.values():
if hasattr(user, 'status'):
print(user.screen_name, user.status.text)
@jbn
Copy link
Author

jbn commented Mar 6, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment