PRAW:Python Reddit API 包装器不工作
PRAW: Python Reddit API Wrapper not working
我正在尝试制作一个 Reddit 机器人,但我什至无法使用以下简单示例,也无法使用 PRAW 在其文档中提供的示例。
如下代码
import praw
r = praw.Reddit(user_agent="some useragent text")
r.login()
returns下面的错误
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 似乎比 python 比 Reddit API 更容易使用,所以我宁愿坚持使用它。此外,login()
似乎已贬值,那么我如何使用 OAuth2(或其他名称)?
注意:我使用 easy_install praw
安装 PRAW,因为 pip install praw
不工作。我尝试在 Mac OS X 10.12 和 Raspbian 上使用 pip
,但均无效。有什么想法吗?
[Promoted/expanded 来自评论]
正如@bboe 所指出的,PRAW 文档可以位于 here ¹.
具体来说,您需要 Getting Started ¹ 页面,该页面会引导您以只读或 read/write 模式实例化 Reddit 对象。
¹ PRAW 4 文档不再在线提供,因此我更新了链接以跟踪最新版本。
我正在尝试制作一个 Reddit 机器人,但我什至无法使用以下简单示例,也无法使用 PRAW 在其文档中提供的示例。
如下代码
import praw
r = praw.Reddit(user_agent="some useragent text")
r.login()
returns下面的错误
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 似乎比 python 比 Reddit API 更容易使用,所以我宁愿坚持使用它。此外,login()
似乎已贬值,那么我如何使用 OAuth2(或其他名称)?
注意:我使用 easy_install praw
安装 PRAW,因为 pip install praw
不工作。我尝试在 Mac OS X 10.12 和 Raspbian 上使用 pip
,但均无效。有什么想法吗?
[Promoted/expanded 来自评论]
正如@bboe 所指出的,PRAW 文档可以位于 here ¹.
具体来说,您需要 Getting Started ¹ 页面,该页面会引导您以只读或 read/write 模式实例化 Reddit 对象。
¹ PRAW 4 文档不再在线提供,因此我更新了链接以跟踪最新版本。