Twython:获取除静音列表中的所有关注者之外的所有关注者的列表?

Twython: Get a list of all your followers except those who are on your muted list?

我有这段代码可以让我的 Twitter 关注者使用 Twython。我将如何修改它来代替:

"Get all your twitter followers who do not appear on your muted followers list" ?

我尝试了两次请求,一次针对关注者,一次针对 twitter.list_mutes,然后将两个列表作为集合进行比较。但推特 api 对此不太高兴。

建议?

followers = []
next_cursor = -1

while(next_cursor):
    get_followers = twitter.get_followers_list(screen_name=username, count=200, cursor=next_cursor)
    for follower in get_followers["users"]:
        followers.append(follower["screen_name"].encode("utf-8"))
        next_cursor = get_followers["next_cursor"]

print "%s followers found" % str(len(followers))

好的。找到了一种方法来做到这一点,但它并不优雅。它起作用了。我只是制作了不同的光标以传递给不同的循环。然而,可能有更好的方法来做到这一点,所以请随时在这里发表评论。

https://github.com/sharkwheels/twitter_muter/blob/master/randoMute.py

### GET FOLLOWERS ##################

    while(next_cursor):
        get_followers = twitter.get_followers_list(screen_name=username, count=200, cursor=next_cursor)

        for follower in get_followers["users"]:
            followers.append(follower["screen_name"].encode("utf-8"))
            next_cursor = get_followers["next_cursor"]

    print "%s followers found" % str(len(followers))
    print " "
    print "get muted users"


    ## GET ALREADY MUTED FOLLOWERS ##################

    while(butts_cursor):
        get_muted = twitter.list_mutes(screen_name=username, count=200, cursor=butts_cursor)

        for x in get_muted["users"]:
            silent_followers.append(x["screen_name"].encode("utf-8"))
            butts_cursor = get_muted["next_cursor"]

    print " "
    print "%s silent_followers found" % str(len(silent_followers))
    print silent_followers