Created
March 6, 2021 03:51
-
-
Save infominer33/6f4eea33b1451dd593a441b658365405 to your computer and use it in GitHub Desktop.
Export twitter list members (JSON)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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