我正在尝试创建一个Reddit bot,当提到用户名时,它会获取用户注释并将其发送到API来分析它们并返回请求但是当我尝试下载它们时它会给我
prawcore.exceptions.BadRequest: received 400 HTTP response
这是代码:
if text.startswith('/u/PersonalityInsights'):
print "Mentioned!"
print comment
username = text.split()[1]
print username
if username.startswith('/u/'):
validusername = username[3:]
print validusername
global redditor
redditor = bot.redditor(username)
else:
global redditor
redditor = bot.redditor(username)
file = codecs.open('userscommentsreddit.txt', 'w+', encoding='utf8')
for comment in redditor.get_comments(limit=None):
print comment.body
我正在使用的方法是:get_comments(limit=None)
在PRAW 3中它起作用但在这里它失败了。我尝试降低用户名,但失败并出现同样的错误。我正在尝试下载评论的帐户是我的:/ u / UnknownDeveloper
我尝试降低用户名,但同样的错误,用这个替换for循环:for comment in redditor.comments.new(limit=None):
仍然是一个错误400
如果您对完整代码感兴趣,请点击此处链接到GitHub gist。
版权4.1.0