【问题标题】:Tweeter API: How do I use Tweepy.cursor to search by key word (e.g. trump) and search by number of followers (e.g. greater than 10000)Twitter API:如何使用 Tweepy.cursor 按关键字搜索(例如 trump)和按关注者数量搜索(例如大于 10000)
【发布时间】:2020-03-19 15:46:48
【问题描述】:
results = [] 
for tweet in tweepy.Cursor(api.search,
                           q="coronavirus",
                           result_type="recent",
                           include_entities=True,
                           wait_on_rate_limit=True,
                           wait_on_rate_limit_notify=True,
                           lang="en").items(50):
        results.append(tweet)

我知道如何使用 tweepy.cursor 搜索关键字。但我只想附加特定用户拥有超过 10000 个关注者并满足关键字标准的推文。我不确定如何同时做这两件事。有人可以帮忙吗?谢谢!

【问题讨论】:

    标签: tweepy


    【解决方案1】:

    以下是 Twitter 状态 JSON 示例:https://pastebin.com/UB5XbrHe

    "user":{
      ...
      "followers_count":46,
      ...
    }
    

    您可以通过tweet._json 访问您案例中的 json。而不是

    results.append(tweet)
    

    你会写:

    if tweet._json["user"]["followers_count"] > 10000:
      results.append(tweet)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-11
      • 1970-01-01
      • 1970-01-01
      • 2017-10-23
      • 2019-12-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多