I'm using the following code to submit a self post. Once that is submitted I would like the url to that post to be stored in a variable. I'm new to python and praw so i'm probably missing something obvious.
import praw
sub_reddit = 'test'
user_agent = 'user agent info'
post_title = 'post title text'
post_body = 'post body text'
r = praw.Reddit(user_agent=user_agent)
def login():
r.login('USERNAME', 'PASSWORD')
def self_post():
r.submit(sub_reddit, post_title, text=post_body)
login()
self_post()
Looking through the documentation I found this that states the return of .submit is as follows:
"The newly created Submission object if the reddit instance can access it. Otherwise, return the url to the submission.
If that is the case, how do I get that link? I can't run a lot of different test because the API has a limit on submissions so I keep getting blocked from trying new things.
return the response and assign it to a variable:
def self_post():
return r.submit(sub_reddit, post_title, text=post_body)
login()
resp = self_post()