【发布时间】:2016-02-02 00:13:07
【问题描述】:
我正在尝试获取有关特定用户关注的所有 Twitter 朋友的一些基本信息。我正在使用 for 循环来获取此信息,但如果用户有很多朋友,我会收到速率限制错误。我正在尝试并努力将一种绕过速率限制的方法集成到我的 for 循环中。感谢您的任何建议!
我的原始代码:
data = []
for follower in followers:
carrot = api.get_user(follower)
data.append("[")
data.append(carrot.screen_name)
data.append(carrot.description)
data.append("]")
我试图绕过速率限制错误:
data = []
for follower in followers:
carrot = api.get_user(follower,include_entities=True)
while True:
try:
data.append("[")
data.append(carrot.screen_name)
data.append(carrot.description)
data.append("]")
except tweepy.TweepError:
time.sleep(60 * 15)
continue
except StopIteration:
break
【问题讨论】:
-
嗨!欢迎来到Stack Overflow!你的错误信息是什么?看看minimal reproducible example 是什么...
标签: python for-loop tweepy rate-limiting