我想使用 praw 抓取 reddit 数据.添加 for 循环后,我收到了 raise ResponseException(response) 错误 [英] I want to scrape reddit data using praw. I am getting raise ResponseException(response) error after adding the for loop
问题描述
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)
收到此错误
文件C:\Users\source\repos\lib\site-packages\prawcore\auth.py",行31、在_post引发 ResponseException(response)
File "C:\Users\source\repos\lib\site-packages\prawcore\auth.py", line 31, in _post raise ResponseException(response)
ResponseException: 收到 401 HTTP 响应
ResponseException: received 401 HTTP response
推荐答案
401 错误 表示您的请求缺少目标资源的有效身份验证凭据.您需要使用 reddit api验证自己.
但是,如果您只想获取数据,则可以使用 只读模式 或向reddit api请求数据自己
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
这篇关于我想使用 praw 抓取 reddit 数据.添加 for 循环后,我收到了 raise ResponseException(response) 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!