Skip to content

Instantly share code, notes, and snippets.

@infominer33
Created March 6, 2021 03:51
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 infominer33/6f4eea33b1451dd593a441b658365405 to your computer and use it in GitHub Desktop.
Save infominer33/6f4eea33b1451dd593a441b658365405 to your computer and use it in GitHub Desktop.
Export twitter list members (JSON)
#!/usr/bin/env python
# encoding: utf-8
import tweepy # https://github.com/tweepy/tweepy
TWITTER_C_KEY = # your consumer_key here
TWITTER_C_SECRET = # your consumer_secret here
TWITTER_A_KEY = # your app access_token here
TWITTER_A_SECRET = # your access_token_secret here
#authorize twitter, initialize tweepy
auth = tweepy.OAuthHandler(TWITTER_C_KEY, TWITTER_C_SECRET)
auth.set_access_token(TWITTER_A_KEY, TWITTER_A_SECRET)
api = tweepy.API(auth)
list_id = 1322189089072926721
def get_list_members(api, list_id):
members = []
# without this you only get the first 20 list members
for page in tweepy.Cursor(api.list_members, list_id=list_id).items():
members.append(page) # create a list containing all usernames
for m in members:
print(m)
return [ m.screen_name for m in members ]
get_list_members(api, list_id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment