Reputation: 83
subredditcmv=reddit.subreddit('changemyview')
cmv_subreddit=subredditcmv.top(limit=15)
cmv_dict={"Title":[], \
"Score":[], \
"id":[], \
"number_of_comments":[],\
"post":[],\
"created":[]
}
for posts in cmv_subreddit:
cmv_dict["Title"].append(posts.title)
cmv_dict["Score"].append(posts.score)
cmv_dict["id"].append(posts.id)
cmv_dict["number_of_comments"].append(posts.num_comments)
cmv_dict["post"].append(posts.selftext)
cmv_dict["created"].append(posts.created)
receiving this error
File "C:\Users\source\repos\lib\site-packages\prawcore\auth.py", line 31, in _post raise ResponseException(response)
ResponseException: received 401 HTTP response
Upvotes: 5
Views: 9968
Reputation: 1204
The 401 error mean that your request lacks valid authentication credentials for the target resource. You need to authenticate yourself with the reddit api.
However, if you only want to fetch data, you can use the read-only mode or request the data to the reddit api yourself
Upvotes: 3
Reputation: 247
You are not authenticated with reddit's API (see the PRAW authentication page). Logging in first should fix this issue.
Upvotes: 1