I'm trying to scrape reddit comments, and I'm having difficulty sending requests to reddit. It seems that somewhere along my short script some bad syntax has occurred. Can anyone spot it?
I've tried with and without the redirect_uri. Under my Reddit app page it says my app is authorized. I also tried changing the user_agent name to something else besides my username but that still didn't work. I'm unsure what other information to provide.
import praw #Python Reddit API Wrapper
reddit = praw.Reddit(client_id='ID', \ #the personal number
client_secret='SECRET', \ #the secret number
user_agent='Username', \ #Identical to username
username='Username', \ #Identical to user_agent
password='PW', \
redirect_uri='http://localhost:8080')
#confirm connection:
print(reddit.user.me()) # this works and returns my Username
submission = reddit.submission("https://www.reddit.com/r/funny/comments/ch6oz0/amasian/")
submission.comments #this fails and returns:
File "/lib/python3.6/site-packages/prawcore/sessions.py", line 130, in _request_with_retries
raise self.STATUS_EXCEPTIONS[response.status_code](response)
BadRequest: received 400 HTTP response
help(reddit.submission)
Help on method submission in module praw.reddit:
submission(id=None, url=None) method of praw.reddit.Reddit instance
Return a lazy instance of :class:`~.Submission`.
:param id: A reddit base36 submission ID, e.g., ``2gmzqe``.
:param url: A URL supported by
:meth:`~praw.models.Submission.id_from_url`.`.
Either ``id`` or ``url`` can be provided, but not both.
submission() thinks I was entering an ID because I didn't specify url=''.
Can't mourn too hard, case closed, folks.