Skip to main content
 首页 » 编程设计

python之推文对象中缺少 reply_count 属性

2024年09月07日14kevingrace

我正在尝试检索特定推文的回复计数(使用 tweet.retweet_count)。但我收到属性未找到错误。似乎推文对象中缺少此属性。但是当我检查推文对象的文档时,它已列出并且应该可用。我是不是漏了什么?

文档 - https://developer.twitter.com/en/docs/tweets/data-dictionary/overview/tweet-object

我正在使用 python,下面是我的代码:

for tweet in alltweets: 
    outtweets.append([tweet.id_str, tweet.created_at, tweet.text.encode("utf-8"),tweet.place,tweet.source,tweet.reply_count,tweet.retweet_count,tweet.favorite_count,tweet.retweeted,tweet.lang]) 

我的 outtweets 列表是空的 :( 尝试了很多推文

请您参考如下方法:

尽管 reply_count 被记录为在 Tweet 对象上可用,但不幸的是,它是 premium API 的一部分:

That field is only offered in the premium and enterprise API tiers and we need to do better at documenting this restriction.

( reference )