您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

python – 使用tweepy和多个API密钥获取Twitter粉丝

5b51 2022/1/14 8:20:25 python 字数 1534 阅读 492 来源 www.jb51.cc/python

我有多个twitter开发键,我用它来从句柄列表中获取关注者.我有两种方法可以做到这一点,但两者都有问题.首先: try: .... for user in tweepy.Cursor(api.followers, screen_name=screenName).items(): .... except tweepy.TweepError as e: errorC

概述

try:
    ....
    for user in tweepy.Cursor(api.followers,screen_name=screenName).items():
    ....
except tweepy.TweepError as e:

    errorCode = e.message[0]['code']
        if errorCode == 88:
            print "Rate limit exceeded."
            rotateKeys()

这里的问题是每次我旋转键时,for循环从头开始并再次开始获得追随者.我试图绕过这个,但拆分for循环:

try:
    items = tweepy.Cursor(api.followers,screen_name=s).items()

然后我使用next(items)手动循环它们

但是,旋转api键不起作用,因为初始调用是使用第一个API代码完成的,并且将始终尝试使用该API.

我需要一种方法来旋转键并继续前一个左侧.

current_cursor = cursor.iterator.next_cursor
# re-create the cursor using the new api instance
cursor = tweepy.Cursor(api.followers,screen_name=s,cursor=current_cursor)

总结

以上是编程之家为你收集整理的python – 使用tweepy和多个API密钥获取Twitter粉丝全部内容,希望文章能够帮你解决python – 使用tweepy和多个API密钥获取Twitter粉丝所遇到的程序开发问题。


如果您也喜欢它,动动您的小指点个赞吧

除非注明,文章均由 laddyq.com 整理发布,欢迎转载。

转载请注明:
链接:http://laddyq.com
来源:laddyq.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


联系我
置顶