微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

获取对推文的所有回复 (Tweepy) 仅提取最近的 50 条推文

如何解决获取对推文的所有回复 (Tweepy) 仅提取最近的 50 条推文

我正在寻找对推文的回复

https://twitter.com/ChrisCillizza/status/911224143022092289

为此,我设置了我的帐户

api_key = 'REDACTED'
api_secret_key = 'REDACTED'
access_token = 'REDACTED'
access_token_secret = 'REDACTED'
auth = tweepy.OAuthHandler(api_key,api_secret_key)
auth.set_access_token(access_token,access_token_secret)
api_out = tweepy.API(auth)

然后我拉出有问题的推文

tweet_id = 911224143022092289
tweet = api_out.get_status(tweet_id) ## This gets the tweet object
tweet_text = tweet.text ## The tweets text
tweet_user = tweet.user.screen_name ## The screen name of the user making teh tweet
tweet_date = tweet.created_at ## The date of the tweet

然后我使用这条推文中的信息来尝试提取回复

tmpTweets = api_out.search(q='to:{}'.format(tweet_user),tweet_mode='extended',count=1000) ## Get 
the tweets mentioning the user since the tweet

我终于尝试过滤推文以让回复的人回复

for tw in tmpTweets : ## Cycle through every tweet pulled
    if tw.in_reply_to_status_id == tweet_id : ## If this tweet mentioning the user was in reply to the tweet we're interested in
        replies.append(tw)
    else :
        print(str(tw.in_reply_to_status_id) + " " + str((tw.created_at)))

但是我最终得到的数据集只有 55 条推文,而且都是从今天开始的。
这令人困惑有两个原因 --

(1) Why is it not finding tweets related to the original?
(2) Why is it only pulling the most recent 55 tweets? 

如果我假设上面 (1) 的答案是“这条推文太旧了”,我希望以该用户最近的 1000 次提及结束,但我只收到最近的 50 次。

谢谢

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。