gpt4 book ai didi

python - PRAW:Python Reddit API 包装器不工作

转载 作者:太空宇宙 更新时间:2023-11-04 00:44:35 25 4
gpt4 key购买 nike

我正在尝试制作一个 Reddit 机器人,但我什至无法使用以下简单示例,也无法使用 PRAW 在其文档中提供的示例。

下面的代码

import praw
r = praw.Reddit(user_agent="some useragent text")
r.login()

返回以下错误

Traceback (most recent call last):
File "savageAxeBot.py", line 3, in <module>
r = praw.Reddit(user_agent="some useragent text")
File "/Library/Python/2.7/site-packages/praw-4.0.0b21-py2.7.egg/praw/reddit.py", line 101, in __init__
raise ClientException(required_message.format(attribute))
praw.exceptions.ClientException: Required configuration setting 'client_id' missing.
This setting can be provided in a praw.ini file, as a keyword argument to the `Reddit` class constructor, or as an environment variable.

更新:我已经获得了我的客户端 ID 和密码。我设法让上面的代码(完全如图所示)在 Fedora 24 上工作,但无法让它在 Raspbian 或 Mac OS X 上工作。

PRAW 似乎比 Reddit API 更容易从 python 使用,所以我宁愿坚持使用它。此外,login() 似乎已贬值,那么我如何使用 OAuth2(或它的名称)?

注意:我使用 easy_install praw 安装了 PRAW,因为 pip install praw 不工作。我尝试在 Mac OS X 10.12 和 Raspbian 上使用 pip,但都没有用。有什么想法吗?

最佳答案

[从评论中提升/扩展]

正如@bboe 所指出的,PRAW 文档可以位于 here ¹.

具体来说,您需要 Getting Started ¹ 页面引导您以只读或读/写模式实例化 Reddit 对象。

¹ PRAW 4 文档不再在线提供,因此我更新了链接以跟踪最新版本。

关于python - PRAW:Python Reddit API 包装器不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40293494/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com