我正在尝试在pythoneverywhere上运行一个机器人,我目前在我的电脑上运行它,但我想把它移到云端。当它试图评论一个帖子时我得到了错误,
AttributeError:' class' praw.objects.Submission''没有属性'回复'
我已经在线查看了官方的文档,我使用的代码应该可以使用,它可以通过电脑工作。
#!/usr/bin/python
import praw
import pdb
import re
import os
import threading
import time
# Create the Reddit instance
#
# and login
#reddit.login(REDDIT_USERNAME, REDDIT_PASS)
reddit = praw.Reddit(Private INfo)
soccer_array = ['Keyword']
soccer_link = [
"comment",
]
def soccer():
subreddit = reddit.get_subreddit('sub')
print("Checking Soccer")
for submission in subreddit.get_new(limit=40):
#print(submission.title)
i = 0
while i <= (len(soccer_array) - 1):
# If we havent replied to this post before
# Do a case insensitive search
if re.search(soccer_array[i], submission.title, re.IGNORECASE):
# Reply to the post
submission.reply(soccer_link[i])
print('')
print("Bot replying to: ", submission.title)
print('')
del soccer_array[i]
del soccer_link[i]
time.sleep(1000)
else:
i += 1
else:
i += 1
def should_reset_timer():
pass
def main():
soccer()
timer = 0
while True:
time.sleep(1)
timer+=1
if should_reset_timer():
timer = 0
if timer == 10*60:
soccer()
timer = 0
main()
&#13;
答案 0 :(得分:1)
您需要在服务器上更新PRAW。在您的PC上,您有PRAW&gt; = 4,但您服务器上安装的版本是&lt; 4。
我知道这一点,因为你的追溯提到praw.objects.Submission
,但当前版本的PRAW有praw.models.Submission
。另一方面,PRAW 3有praw.objects.Submission
。