是否可以通过Twitter API使用Tweepy下载10000名用户的推文和转发?



我需要建议。

我正在尝试了解Twitter API速率限制。

我有一个包含大约 10000 个 Twitter 句柄的 csv 文件。

我需要下载这些用户的推文和转发。

如果我遍历句柄并下载数据 - 这将如何影响 Twitter 的速率限制?我的脚本可以在不被列入黑名单的情况下拨打多少个电话?

这可以通过流 API 代替吗?

为此,我将使用 Python 和 Tweepy。

提前谢谢。

这是可能的,但您需要错开它以遵守速率限制。我使用这样的东西(来自以前的答案:1、2(:

alltweets = []
new_tweets = api.user_timeline(screen_name = screen_name,count=200) 
# save most recent tweets
alltweets.extend(new_tweets)
# save the id of the oldest tweet less one
oldest = alltweets[-1].id - 1
#keep grabbing tweets until there are no tweets left to grab
while new_tweets:       
try:
new_tweets = api.user_timeline(screen_name = screen_name,count=200,max_id=oldest)
except tweepy.TweepError:
time.sleep(60 * 15)
continue

'''

最新更新