A memo when I wanted a list of followers / followers' lists and made Tools for making such things.
At first I thought I'd do it with Tweepy, but I couldn't find a function to get lists other than myself, that is, lists / list, lists / ownerships, lists / subscriptions, etc.
I ended up doing it myself. I wonder why ...
from requests_oauthlib import OAuth1Session
import json
session = OAuth1Session(consumer_key, consumer_secret, access_token, access_token_secret)
api_url = 'https://api.twitter.com/1.1/lists/ownerships.json'
params = {'user_id': userid}
req = session.get(api_url, params=params)
if req.status_code == 200:
    jsn = json.loads(req.text)
    for item in jsn['lists']:
        print(item['name'])
else:
    print('Error: %d' % req.status_code)
        Recommended Posts