【问题标题】:Tweepy lookup of extended tweets for multiple tweets at a time?Tweepy 一次查找多条推文的扩展推文?
【发布时间】:2019-03-24 21:12:18
【问题描述】:

我正在使用 tweepy 访问大量推文。许多推文被截断,所以我想获取一些推文的全文,我有 id。

我的问题是:tweepy api 实例有一种方法可以一次下载多条推文(api.statuses_lookup),但这会返回截断的推文。 它还有一个包含完整推文文本(api.get_status)的方法,但 afaik 一次只接收一条推文。 有没有办法一次获取多条推文的全文?

import tweepy

consumer_key = "XXX"
secret = "XXX"
auth = tweepy.AppAuthHandler(consumer_key, secret)
auth.secure = True
api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True)

ids =  [1108360183586140161, 1108474125486641153]

# Finds tweets (up to 100 at a time), but doesn't contain extended text
foo = api.statuses_lookup(ids)

# Returns tweet, including extended text, but only for one at a time
bar = api.get_status(1108449077937635328, tweet_mode='extended')

【问题讨论】:

  • 你是说api.statuses_lookup也不支持tweet_mode参数吗?
  • 正确。尝试给出: statuses_lookup() got an unexpected keyword argument 'tweet_mode'
  • 看来您需要 3.7.0 或更高版本 github.com/tweepy/tweepy/issues/840
  • 啊,谢谢!如果对其他人有帮助,我会添加答案。

标签: python api twitter tweepy


【解决方案1】:

正如Andy Piper 所指出的,该问题已在最近更新的 Tweepy 库中得到修复,因此正在运行

pip install tweepy --upgrade

解决了这个问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-07-05
    • 2015-06-20
    • 2020-04-11
    • 2016-02-09
    • 1970-01-01
    • 2017-09-04
    • 2018-10-07
    • 2017-08-20
    相关资源
    最近更新 更多