Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 我怎样才能从Twitter用户那里获得一个庞大的关注者列表,然后跟踪他们?_Python_Python 3.x_Twitter_Tweepy - Fatal编程技术网

Python 我怎样才能从Twitter用户那里获得一个庞大的关注者列表,然后跟踪他们?

Python 我怎样才能从Twitter用户那里获得一个庞大的关注者列表,然后跟踪他们?,python,python-3.x,twitter,tweepy,Python,Python 3.x,Twitter,Tweepy,我怎样才能从一个拥有大量追随者的Twitter帐户中获得追随者列表?我的代码意味着从一个用户那里获得追随者,然后跟随他们,但我能获得和跟随的最大值是200,在我的代码中,然后在200之后,它会获得新用户,但速度要慢得多。有没有办法再多赚几千 import tweepy from time import sleep consumer_key = '' consumer_secret = '' access_key = '' access_secret = '' auth = tweepy.OA

我怎样才能从一个拥有大量追随者的Twitter帐户中获得追随者列表?我的代码意味着从一个用户那里获得追随者,然后跟随他们,但我能获得和跟随的最大值是200,在我的代码中,然后在200之后,它会获得新用户,但速度要慢得多。有没有办法再多赚几千

import tweepy
from time import sleep

consumer_key = ''
consumer_secret = ''
access_key = ''
access_secret = ''

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_key, access_secret)

api = tweepy.API(auth)

users = tweepy.Cursor(api.followers, screen_name='twitter', count=200).items()
count = 0

while True:
    try:
        user = next(users)
        api.create_friendship(user.screen_name)
        sleep(1)
        print(user.screen_name)

    except tweepy.TweepError as e:
        if e.api_code == 161:
            while(count < 901):
                print(count, end='\r')
                sleep(1)
                count +=1
        if e.api_code == 160:
            pass
    except StopIteration:
        pass
导入tweepy
从时间上导入睡眠
消费者密钥=“”
消费者机密=“”
访问密钥=“”
访问密码=“”
auth=tweepy.OAuthHandler(使用者密钥,使用者密钥)
授权设置访问令牌(访问密钥、访问密钥)
api=tweepy.api(auth)
users=tweepy.Cursor(api.followers,screen_name='twitter',count=200).items()
计数=0
尽管如此:
尝试:
用户=下一个(用户)
api.创建友谊(用户.屏幕名称)
睡眠(1)
打印(用户屏幕名称)
除tweepy.TweepError为e外:
如果e.api_代码==161:
而(计数<901):
打印(计数,结束='\r')
睡眠(1)
计数+=1
如果e.api_代码==160:
通过
除停止迭代外:
通过
表示api的count参数限制为200。我猜这会给你带来麻烦

每页返回的用户数,最多为200。默认值为20

检查你的

在服务器开始限制访问之前,通常对您可以拨打的电话数量有限制。其原因是,如果他们让每台服务器每分钟ping 1000多次,其服务器的成本将更高,并且更难发现DNS攻击(攻击性服务器在看起来仍然像非攻击性服务器的情况下,可以拨打的呼叫数量很高)