Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting NSFW submissions with praw

Tags:

python

praw

I'm using PRAW to scrape for some content from reddit. I can get info on a submission (praw.objects.Submission), but I don't see from the documentation how to tell if the post is flagged as NSFW or not. Is it possible to figure this out through PRAW or should I use another api wrapper?

like image 486
dunstantom Avatar asked Nov 11 '15 02:11

dunstantom


1 Answers

You may figure it out through PRAW by retrieving a submission object, and then applying over_18 to the object itself (as @Kevin suggested).

Here's an example:

if submission.over_18:
    ...
else:
    ...

And for future references, by using "dir(object)," you'll be able to see both attributes and methods that pertain to the Reddit API (which you may use to test and see all properties that effect the given object being tested). You can ignore everything that starts with an underscore (most likely).

Or you can go straight to source where PRAW is getting its data. The variable names are not set by PRAW, they come from this JSON (linked above).

like image 68
Saroekin Avatar answered Oct 29 '22 19:10

Saroekin