python - Praw AttributeError: 'NoneType' object has no attribute 'get_comments' -



python - Praw AttributeError: 'NoneType' object has no attribute 'get_comments' -

i wrote simple script identifying users contribute subreddits. disclaimer, if plan on using code should sure anonymize info (as will, aggregating info , removing usernames). works subreddits not seem robust, seen next error when run /r/nba:

attributeerror: 'nonetype' object has no attribute 'get_comments'

below code:

import praw import pprint users = [] #[username, flair, comments] r=praw.reddit(user_agent="user_agent") r.login("username", "password") submissions = r.get_subreddit('nba').get_top(limit=1) #won't work higher limit? submission in submissions: submission.replace_more_comments(limit=3, threshold=5) flat_comments = praw.helpers.flatten_tree(submission.comments) comment in flat_comments: user_comments = [] in comment.author.get_comments(limit=2): user_comments.append(i.body) #user_comments.append(str(i.body)) #sometimes causes error users.append([str(comment.author), comment.author_flair_text, user_comments]) pprint.pprint(users)

when alter subreddit 'python' seems encounter less problems, can point out i'm missing. in advance!

ok, see line

for in comment.author.get_comments(limit=2):

i presume code failing because

comment.author none

python reddit praw

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -