【问题标题】:Is it possible to download tweets and retweets of 10000 users with Tweepy through Twitter API? [closed]是否可以通过 Twitter API 使用 Tweepy 下载 10000 名用户的推文和转推? [关闭]
【发布时间】:2018-02-02 17:01:11
【问题描述】:

我需要一个建议。

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

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

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

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

这可以用 Stream API 代替吗?

我将为此使用 Python 和 Tweepy。

提前致谢。

【问题讨论】:

    标签: python twitter tweepy


    【解决方案1】:

    这是可能的,但您需要错开它以遵守速率限制。我使用这样的东西(来自以前的答案: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
    

    ```

    【讨论】:

      猜你喜欢
      • 2021-04-30
      • 2021-12-31
      • 1970-01-01
      • 2014-10-29
      • 2020-07-21
      • 2013-09-05
      • 2015-03-31
      • 2013-09-23
      • 1970-01-01
      相关资源
      最近更新 更多