0

我在使用以下代码获得的列表中拥有所有关注者 ID。现在我想获取所有这些 ID 的信息(followers_countfriends_countverified等)为了每 15 分钟获得 18000 个结果,我需要进行哪些更改。我在 15 分钟内使用以下代码获得了 75000 个 ID。

counter = 0
reset_counter = 0
loop_counter = True
backoff_timer = 2 # counter for timer

while loop_counter:
    try:
        for friend in tweepy.Cursor(api.followers_ids, id='adl440', count=5000).items():
            time.sleep(0.01)
            reset_counter += 1 # reser 1
            # this is reducing the waiting time

            counter += 1 #count 1
            # max collection 5*15K =75K in 15 mins
            # insert the information into the table
            #uid_json = {'uid': friend}
            #collection.insert_one(uid_json)
            # # saving the txt file
            
            print(str(friend))
            csvWriter.writerow(str(friend))
            count +=1
            print(count)

        break

    except tweepy.TweepError as err:
        print(err.reason)
        time.sleep(60 * backoff_timer)
        sleep_time = 60 * backoff_timer
        print('Error Generated by Tweepy API sleep {0} seconds.'.format(round(sleep_time,2)))
        backoff_timer += 1
        continue

我尝试使用 API 查找方法获取数据,但未能成功。每次我尝试时,我的输出结果都很少,突然我达到了速率限制。

4

1 回答 1

0

The GET users/lookup Twitter API endpoint that API.lookup_users uses returns 100 users per request. The rate limit for the endpoint is 900 requests / 15 min. with user auth and 300 requests / 15 min. with app auth. This means that you should be able to retrieve 30,000 or 90,000 users per 15-min. window, depending on if you're using app auth or user auth.

于 2021-05-27T10:23:41.750 回答