使用Praw,你如何评论通过一个网址链接 [英] Using Praw how do you get comment linked by a URL
本文介绍了使用Praw,你如何评论通过一个网址链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想获得一个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?
推荐答案
在我到底是一个有点哈克方式:
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,你如何评论通过一个网址链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文