lordlabakdas lordlabakdas - 5 months ago 40
Python Question

get URL of any submission for subreddits

I am trying to use PRAW to get new posts from subreddits on Reddit. The following code snippet shows how I get new items on a particular subreddit.

Is there a way to also get the URL of the particular submission?

submissions = r.get_subreddit('todayilearned')
submission = submissions.get_new(limit=1)
sub = [str(x) for x in submission]
print sub


PRAW allows you to do this:

To get the submitted link you can use submission.url

[submission] = submissions.get_new(limit=1)
print submission.url

Or if you're looking for the URL for the actual post to Reddit then you can use permalink

[submission] = submissions.get_new(limit=1)
print submission.permalink