如何获取reddit评论的嵌入json?

2024-09-29 01:27:13 发布

您现在位置:Python中文网/ 问答频道 /正文

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

如何检索这些数据?你知道吗


Tags: httpsimportgithubcomconsumerresponsewwwwiki
1条回答
网友
1楼 · 发布于 2024-09-29 01:27:13

reddit返回的oembed无效。你知道吗

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

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

您可能需要让reddit来修复损坏的oembed实现,或者您可能希望使用更宽容的库。你知道吗

相关问题 更多 >