2016-06-21 41 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來修復其破損的實現,或者您可能想要使用更多的原諒庫。