使用Tweepy获取关注者信息



我使用以下代码获得了一个列表中的所有追随者ID。现在,我想获得所有这些ID的信息(followers_countfriends_countverified等(。为了每15分钟获得18000个结果,我需要做哪些更改。我用下面的代码在15分钟内得到了75000个身份证。

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查找方法获取数据,但没有成功。每次我尝试时,输出的结果都很小,突然我达到了速率限制。

API.lookup_users使用的GET用户/查找Twitter API端点每次请求返回100个用户。端点的速率限制为900个请求/15分钟(使用用户身份验证(和300个请求/15分钟(使用应用程序身份验证(。这意味着您应该能够在每15分钟内检索30000或90000个用户。窗口,这取决于您使用的是应用程序身份验证还是用户身份验证。

最新更新