2016-06-21 52 views
2

我试图用python-oembed库得到reddit的(https://github.com/reddit/reddit/wiki/oEmbed)透过oEmbed评论:我如何获得odit的json的reddit评论?

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

由reddit返回的oembed无效。

http://oembed.com/,§2.3.4.4,widthheightrich类型所必需的。

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

您可能需要获取reddit来修复其破损的实现,或者您可能想要使用更多的原谅库。