【问题标题】:How can I get oembed json for reddit comment?如何获得用于 reddit 评论的 oembed json?
【发布时间】:2016-10-23 02:18:25
【问题描述】:

我正在尝试使用 python-oembed 库从 reddit(https://github.com/reddit/reddit/wiki/oEmbed) 获取 oembed 评论:

import oembed

consumer = oembed.OEmbedConsumer()
endpoint = oembed.OEmbedEndpoint('https://www.reddit.com/oembed',['https://www.reddit.com/r/*'])

consumer.addEndpoint(endpoint)

response = consumer.embed('https://www.reddit.com/r/Showerthoughts/comments/2safxv/we_should_start_keeping_giraffes_a_secret_from/cno7zic')

并得到oembed.OEmbedError: Missing required fields on OEmbed rich response. 错误。

如何检索这些数据?

【问题讨论】:

    标签: python python-3.x oembed reddit


    【解决方案1】:

    reddit返回的oembed无效。

    rich 类型需要来自 http://oembed.com/、§2.3.4.4、widthheight

    但是,从 the reddit sample,我们看到 reddit 不提供 widthheight 值。

    您可能需要获取 reddit 来修复他们损坏的 oembed 实现,或者您可能想要使用更宽容的库。

    【讨论】:

      猜你喜欢
      • 2021-09-25
      • 2016-04-29
      • 2020-05-23
      • 1970-01-01
      • 2013-01-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多