-
Notifications
You must be signed in to change notification settings - Fork 323
/
twitter-list-lists.py
executable file
·45 lines (36 loc) · 1.73 KB
/
twitter-list-lists.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python3
#-----------------------------------------------------------------------
# twitter-list-lists
# - lists the lists owned by each of a list of users
#-----------------------------------------------------------------------
from twitter import *
#-----------------------------------------------------------------------
# the list of users that we want to examine
#-----------------------------------------------------------------------
users = ["ideoforms", "hrtbps", "mocost"]
#-----------------------------------------------------------------------
# load our API credentials
#-----------------------------------------------------------------------
import sys
import pprint
sys.path.append(".")
import config
#-----------------------------------------------------------------------
# create twitter API object
#-----------------------------------------------------------------------
twitter = Twitter(auth=OAuth(config.access_key,
config.access_secret,
config.consumer_key,
config.consumer_secret))
#-----------------------------------------------------------------------
# for each of our users in turn...
#-----------------------------------------------------------------------
for user in users:
print("@%s" % (user))
#-----------------------------------------------------------------------
# ...retrieve all of the lists they own.
# twitter API docs: https://dev.twitter.com/rest/reference/get/lists/list
#-----------------------------------------------------------------------
result = twitter.lists.list(screen_name=user)
for list in result:
print(" - %s (%d members)" % (list["name"], list["member_count"]))