我在使用以下代码获得的列表中拥有所有关注者 ID。现在我想获取所有这些 ID 的信息(followers_count
、friends_count
、verified
等)为了每 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 查找方法获取数据,但未能成功。每次我尝试时,我的输出结果都很少,突然我达到了速率限制。