python - 原创推文还是转推?

标签 python twitter tweepy

我将 Tweepy 与 python 一起使用,并试图获取由一组用户创作的原始推文(即,我想排除他们时间轴中实际上是转推的任何推文)。我怎样才能用 Tweepy 做到这一点? 我试过这样的东西,但我不知道它是否有效:

tweets = api.user_timeline(id=user['id'], count=30)
for tweet in tweets:
    if not tweet.retweeted:
        analyze_tweet(tweet)

api.user_timeline() 是否只返回原始推文?还是转推此用户?

最佳答案

默认情况下,Tweepy 不在 user_timeline 中包含转推,因此 tweet.retweeted 将始终为 false。要包含转推,您可以将 include_rts 指定为 True,例如

tweets= api.user_timeline(id=user['id'], count=30,include_rts=True)
for tweet in tweets:
        if not tweet.retweeted:
              analyze_tweet(tweet)
        else:
              #do something with retweet

关于python - 原创推文还是转推?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26181130/

相关文章:

python - 如何根据PANDAS中的groupby字段在for循环中写入to_excel动态文件名?

python - 使用 python 内置函数进行耦合 ODE

python - 以独立于平台的方式处理特定于 Windows 的异常

ios - TwitterKit 不能用 Xcode 6.3 编译

python - Tweepy:带有 'Bad Authentication data' 错误的简单脚本

python - 在 numpy 中缩放(或规范化)这样的数组?

java - 具有回调授权的 JTwitter OAuth

php - 从 Twitter API 获取所有推文和重新推文

python - Tweepy 引用状态 "Status has no attribute quoted_status"

python - 如何获得一周前的推文(使用 tweepy 或其他 python 库)