我怎样才能获得oembed json的reddit评论?

时间:2016-06-21 13:37:01

标签: python python-3.x oembed reddit

我正在尝试使用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.错误。

如何检索此数据?

1 个答案:

答案 0 :(得分:1)

reddit返回的oembed无效。

来自http://oembed.com/,§2.3.4.4,width类型需要heightrich

但是,从the reddit sample开始,我们发现reddit不会提供widthheight值。

您可能需要使用reddit来修复破坏的oembed实现,或者您可能希望使用更宽容的库。