Search code examples
pythonpraw

PRAW - searching for NSFW submissions


I'm noticing that nsfw posts are not showing up when using the search method on a subreddit.

for submission in self.reddit.subreddit('nsfw_subreddit').search('a'): print(submission.title)

Nothing is printed out. However when i use new() or hot() it seems like nsfw subreddits are being shown. Is there any parameter I need to pass in to the search() method that I'm currently missing?

Thanks.


Solution

  • As long as you have "I am over eighteen years old and willing to view adult content" checked in Reddit preferences, changing your search to the following will enable NSFW results:

    for submission in self.reddit.subreddit('nsfw_subreddit').search('a', params={'include_over_18': 'on'}):
        print(submission.title)