在Python Everywhere上运行praw时没有获得属性回复

问题描述 投票:0回答:1

我试图在pythoneverywhere上运行一个机器人,我目前在我的电脑上运行它,但我想将它移动到云端。当它试图评论一个帖子我得到错误,

AttributeError:'class'praw.objects.Submission''没有属性'回复'

我在网上查看了官方的文档,我使用的代码应该可以工作,它可以通过pc工作。

#!/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()
python reddit praw
1个回答
1
投票

您需要在服务器上更新PRAW。在PC上,PRAW> = 4,但服务器上安装的版本<4。

我知道这是因为你的追溯提到praw.objects.Submission,但当前版本的PRAW有praw.models.Submission。另一方面,PRAW 3有praw.objects.Submission

© www.soinside.com 2019 - 2024. All rights reserved.