Help getting URL linked to by Reddit post With PRAW

为君一笑 提交于 2019-12-06 04:24:31

问题


Using Praw I am trying to get the post linked to in the title of a Reddit submission. For example the submission links to this image. I have tried figuring out a way to extract this information from the Submission object in PRAW however even when browsing the source I have not been able to find this information. This seems like something that should be easy so I may be missing something.

Thank you very much for your help.


回答1:


import praw

user_agent = praw.Reddit("my_cool_user_agent")
link = "http://www.reddit.com/r/AdviceAnimals/comments/" + \
        "1adu71/apparently_people_still_need_to_hear_this/"
submission = user_agent.get_submission(link)
print submission.url



回答2:


import praw  

r = praw.Reddit(user_agent='Test Script')
submissions = r.get_subreddit('wtf').get_top(limit=10) 
for item in submissions:
    print item.url


来源:https://stackoverflow.com/questions/15445199/help-getting-url-linked-to-by-reddit-post-with-praw

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!