0

I have this block of code that gets my twitter followers using Twython. How would I modify this to instead do:

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

I tried doing a request twice, one for followers, and one for twitter.list_mutes, then comparing the two lists as sets. But the twitter api wasn't too happy about that.

Suggestions?

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))
mishap_n
  • 578
  • 2
  • 10
  • 23

1 Answers1

0

Alright. Found a way to do it, but its not elegant. It works tho. I just made different cursor to pass to a different loop. However there are probably way better ways to do this, so please feel free to comment here.

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
mishap_n
  • 578
  • 2
  • 10
  • 23