Skip to content

Instantly share code, notes, and snippets.

@DrSensor
Forked from marcan/get_following_profiles.py
Created November 15, 2022 09:58
Show Gist options
  • Save DrSensor/67dd89f7c708b456d6ddc3be34733ad8 to your computer and use it in GitHub Desktop.
Save DrSensor/67dd89f7c708b456d6ddc3be34733ad8 to your computer and use it in GitHub Desktop.
import tweepy, json, time, sys
auth = tweepy.OAuth1UserHandler(
<api keys here>
)
api = tweepy.API(auth)
d = json.loads(open(sys.argv[1]).read().split("=", 1)[1])
BATCH=100
users = []
for i in range(0, len(d), BATCH):
ids = []
for f in d[i:i+BATCH]:
ids.append(f["following"]["accountId"])
u = api.lookup_users(user_id=ids)
users.extend(i._json for i in u)
print(f"{i+100}/{len(d)}")
open("users.json", "w").write(json.dumps(users))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment