【问题标题】:In python, how we extract the replies from each tweet twitter API?在 python 中,我们如何从每条推文 Twitter API 中提取回复?
【发布时间】:2020-12-22 07:21:29
【问题描述】:

我正在尝试从 twitter 中提取每条推文的回复,但我找不到方法。现在,我可以验证 twitter API。 Authenticated API image

Authenticated API response/output

【问题讨论】:

标签: python tweepy twitterapi-python


【解决方案1】:

您好 Jarimjim,欢迎使用 stackoverflow。

对于身份验证,以下代码将对您有所帮助,因为您使用的是 tweepy

import tweepy

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)

api = tweepy.API(auth)

//Example to test authentication.
public_tweets = api.home_timeline()
for tweet in public_tweets:
    print(tweet.text)

现在如果你想获得其他人的所有转推,你可以试试这个。

API.retweets_of_me([since_id][, max_id][, count][, page])

返回经过身份验证的用户最近被他人转发的 20 条推文。

参数:

  • since_id – 仅返回 ID 大于(即 比)指定的 ID 更新。
  • max_id – 仅返回 ID 小于的状态(即较旧的 than) 或等于指定的 ID。
  • count – 每页尝试和检索的结果数。
  • page – 指定要检索的结果页面。注:有 分页限制。

返回类型:
Status 对象列表

所有这些东西都提取自http://docs.tweepy.org/en/latest/

如何获取消费者密钥和秘密访问此link

如何获取访问令牌和访问密码访问此link

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-02-06
    • 1970-01-01
    • 2021-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-05
    • 2013-01-03
    相关资源
    最近更新 更多