使用 Praw 如何获得由 URL 链接的评论 [英] Using Praw how do you get comment linked by a URL
本文介绍了使用 Praw 如何获得由 URL 链接的评论的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试获取 reddit URL 链接的内容,可能是提交或评论,我需要能够获取相应的对象,有人知道如何操作吗?
I am trying to get the content linked to by a reddit URL, it could be a submission OR a comment, and I need to be able to get the corresponding object, does anyone know how to?
推荐答案
最后我做了一个有点hacky的方式:
In the end I did it a bit of a hacky way:
def getObjectFromLink(url):
global r
obj=praw.objects.Submission.get_info(r, url)
if len(url.split('/'))==6:
return obj
else:
return obj.comments[0]
这篇关于使用 Praw 如何获得由 URL 链接的评论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文