因此,我尝试创建一个bot,它使用u/GoldenSights中的一段代码,将sub(r/pics)和(r/polpics)的文章交叉。我升级到了一个新的python发行版,出现了很多错误,我甚至不知道从哪里开始。以下是代码(格式为关闭,错误行为粗体):
Traceback (most recent call last):
File "C:\Users\tonyc\AppData\Local\Programs\Python\Python36-32\Lib\site-
packages\praw\subdump.py", line 84, in <module>
r = praw.Reddit(USERAGENT)
File "C:\Users\tonyc\AppData\Local\Programs\Python\Python36-32\lib\site-
packages\praw\reddit.py", line 150, 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.
这似乎与USERAGENT设置有关。我想我没有正确的配置。你知道吗
USERAGENT = ""
# This is a short description of what the bot does. For example
"/u/GoldenSights' Newsletter bot"
SUBREDDIT = "pics"
# This is the sub or list of subs to scan for new posts.
# For a single sub, use "sub1".
# For multiple subs, use "sub1+sub2+sub3+...".
# For all use "all"
KEYWORDS = ["It looks like this post is about US Politics."]
# Any comment containing these words will be saved.
KEYDOMAINS = []
# If non-empty, linkposts must have these strings in their URL
这是错误行:
print('Logging in')
r = praw.Reddit(USERAGENT) <--here, this is error line 84
r.set_oauth_app_info(APP_ID, APP_SECRET, APP_URI)
r.refresh_access_information(APP_REFRESH)
也在Reddit.py公司地址:
raise ClientException(required_message.format(attribute)) <--- error
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.
首先,您需要将API凭证存储在praw.ini file中。这会让事情变得更加安全,看起来可能会在某种程度上解决你的问题。以下是一个完整的普拉维尼文件看起来像,包括useragent,所以尝试复制这个。你知道吗
等你把事情解决了再告诉我。你知道吗
相关问题 更多 >
编程相关推荐