Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I get the same thing, but a work around using the follower IDs would be something like this (assuming you just want to print the usernames):</p> <pre><code>user = raw_input("Enter Twitter handle to get followers of: ") followids = twitter.get_followers_ids(screen_name = user) for x in followids["ids"]: data = twitter.show_user(user_id=x) print(data["screen_name"]) </code></pre> <p>Obviously you could do anything else you like with those screen names or user IDs (e.g. if using your own followers you could DM everyone the same message).</p> <p>EDIT: The above example works, but it will run into rate limiting problems rapidly so a time delay to check IDs (or do other stuff) in batches would be wise.</p> <p>EDIT 2: Your cursor code didn't work because the cursor count is the wrong format. The <a href="https://dev.twitter.com/docs/misc/cursoring" rel="nofollow">API documentation shows</a> the sort of strings you can expect (e.g. "1374004777531007833"). The use of "count=N" is the number of results per page, which is why you hit the limit of 200 results. What you need to do is get each page, store the data somewhere and check for the "next_cursor" data in the results to get the next page until the value reaches 0.</p> <p>EDIT 3: This works for me (without hitting the rate limits if the follower count is less than around 3,000) using Python 2.7.5 (for Python 3 you'll need to change the raw_input line):</p> <pre><code>import math from twython import Twython from authinfo import * from config import * twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) user = raw_input("Enter Twitter handle to get followers of: ") suser = twitter.show_user(screen_name=user) fnum = 200 pnum = int(math.ceil(float(suser["followers_count"]) / fnum)) pages = [] for i in range(pnum): pages.append("p"+str(i+1)) oldpages = [] for i in range(pnum): oldpages.append("p"+str(i)) p0 = { "next_cursor": -1 } # So the following exec() call doesn't fail. for i in range(pnum): exec(pages[i]+" = twitter.get_followers_list(screen_name=user, count=fnum, skip_status=1, cursor="+oldpages[i]+"['next_cursor'])") followers = [] for p in range(pnum): try: exec("for i in range(fnum): followers.append("+pages[p]+"['users'][i])") except(IndexError): pass print(len(followers)) for x in followers: print("""Name: %s Username: %s """ % (x["name"], x["screen_name"])) </code></pre> <p>The authinfo.py module is where I keep the Twitter OAuth data (because it's static for my scripts) and the config.py module contains client_args variables. Ignore as necessary.</p> <p>Some people (okay, probably a lot of people) don't like to encourage using exec(), but screw it, it works as a proof-of-concept. ;)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload