Help getting URL linked to by Reddit post With PRAW
Asked Answered
M

2

5

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.

Maggiore answered 16/3, 2013 at 3:21 Comment(0)
S
15
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
Synaesthesia answered 16/3, 2013 at 4:12 Comment(0)
S
6
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
Scholem answered 15/10, 2015 at 14:44 Comment(2)
This is the same answer as John has already given - i.e. use the url property - with a different way to get the post. SO is not a database of code snippets, so please don't do that. Instead look for ways that you can improve on existing answersAncona
I disagree. These are different answers. The answer that John gave did not help me with a similar problem, but the answer by Gijs Joost Brouwer did help me.Observance

© 2022 - 2024 — McMap. All rights reserved.