Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Help getting URL linked to by Reddit post With PRAW

Tags:

python

api

reddit

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.

like image 520
WhiteWhim Avatar asked Mar 16 '13 03:03

WhiteWhim


People also ask

How do I get the URL of a Reddit post?

Hit the share button on a post or comment in the Reddit apps and select copy link to get the url.

What does PRAW stand for Reddit?

PRAW (Python Reddit API Wrapper) is a Python module that provides a simple access to Reddit's API. PRAW is easy to use and follows all of Reddit's API rules.

Can you post link to Reddit post?

Head to the specific subreddit you'd like to post to, then click the Create Post button. From here you can post three kinds of things: a Text post, an Image or video, or a Link.


2 Answers

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
like image 104
John Avatar answered Sep 23 '22 11:09

John


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
like image 29
Gijs Joost Brouwer Avatar answered Sep 25 '22 11:09

Gijs Joost Brouwer