Tweepy:在Cursor迭代中间旋转API对象

时间:2015-02-23 23:04:51

标签: python twitter tweepy

所以基本上我试图获得其中许多用户的粉丝。我为此使用了tweepy,每次达到限制时我都不能等待60秒,否则这将花费太长时间。所以这是我的方法,对我来说它是有道理的,因为它跟踪next_cursor(初始化为-1):

while getting_followers:
    try:
        follower_cursors = tweepy.Cursor(api.followers_ids, id=userid, next_cursor=current_cursor)
        for follower_cursor in follower_cursors.pages():
            temp_list = temp_list + follower_cursor
            print "Getting Followers..."

        getting_followers = False

    except Exception as e:
        print "Error obtaining node followers"
        print e
        if str(e) == "Not authorized.":
            print "Not authorized, skipping.", str(userid)
            getting_followers = False
        elif str(e) == "[{'message': 'Sorry, that page does not exist.', 'code': 34}]":
            print e
            getting_followers = False
        else:
            print "Changing accounts."
            api = rotateAccounts()
            current_cursor = follower_cursors.iterator.next_cursor

问题是这不起作用,每次旋转api时Cursor重新启动,它都不记得当前光标

0 个答案:

没有答案
相关问题