如何解决获取来自用户的最新推文和所有顶级回复
所以我使用 api.user_timeline 来获取用户这样的推文-
tweepy.Cursor(api.user_timeline,tweet_mode = 'extended',include_rts=False,id=user).items(9000)
我想知道是否有一种有效的方法来获得对推文的前 N 个顶级回复。我不需要回复回复树。
我试过这个,但它变得太多了,使我经常达到速率限制。
def twint_get_tweet_replies(tweet_id,name):
replies=[]
count = 0
for tweet in tweepy.Cursor(api.search,q='to:'+name,result_type='recent',timeout=10).items(2000):
#print(tweet)
try:
if hasattr(tweet,'in_reply_to_status_id_str'):
if (tweet.in_reply_to_status_id_str==tweet_id):
count += 1
replies.append(tweet)
print(tweet)
if count >=100:
break
except tweepy.TweepError:
time.sleep(60 * 15)
continue
except StopIteration:
break
return replies
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。