#python #reddit #praw
#питон #Reddit #praw
Вопрос:
То, что у меня сейчас есть, — это что-то вроде этого:
Я ищу способ перейти от этого конкретного комментария пользователя x, в котором есть ключевое слово, которое я ищу, чтобы затем перейти к комментариям пользователей и узнать, сколько раз они когда-либо упоминали это ключевое слово.
for submission in acSub.hot(limit=100): for comment in submission.comments: # If the comment has a body, (the main part of a comment), then I can read it. if hasattr(comment, "body"): # First make the comment all lowercase so capitalization is never a worry lcComment = comment.body.lower() print("*") # Check to see if the keyword is in the comment's lowercase version, made for keywords being a list for i in range(len(keywords)): if keywords[i].lower() in lcComment: # Add the current keyword which was detected in the comment's body to this list keywordsFound.append(keywords[i]) # If we've looped through all the keywords if i == len(keywords)-1: # If there were any keywords found if len(keywordsFound) gt; 0: print(keywordsFound) if len(keywordsFound) == 1: # Section I need help on: # Get list of users comments, iterate through it and check how many times the user has said keywords[i] # comment.reply("reply") keywordsFound = []
Также — я понимаю некоторые функции PRAW таким образом, но не знаю, как это реализовать в данном случае.