reddit - 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)
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
解决方案
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
推荐阅读
- list - 可以将宏应用于参数列表吗?
- macos - 使用 Xcode 为 macOS 提供 GTK+ 应用程序
- image - 如何将libtool静态安装的路径交给libjpeg库?
- java - 使用 Dropbox API 为 Dropbox 中的所有文件创建可共享链接
- big-o - 使用网格搜索的超参数调整的计算复杂度是多少?
- c# - 如何获得具有反射的通用列表的实例?
- javascript - 如何将流转换为打字稿中的变量
- square-connect - 是否可以通过现金而不是卡完成付款?
- java - 我想按顺序运行三个@Test 方法
- android - 如何修复“错误:无法解决:com.android.support:support-v4:28.0.0”