我想使用 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)

收到此错误

File "C:\Users\source\repos\lib\site-packages\prawcore\auth.py", line 31, in _post raise ResponseException(response)

ResponseException: received 401 HTTP response

您未通过 reddit 的 API (see the PRAW authentication page) 进行身份验证。先登录应该可以解决这个问题。

401 error mean that your request lacks valid authentication credentials for the target resource. You need to authenticate yourself 与 reddit api。
但是,如果你只想获取数据,你可以自己使用read-only mode or request the data to the reddit api