How to use "selftext:not" parameter
reagle opened this issue · 1 comments
Without the API, I'm able to search via selftext:not
:
pushshift_query = f"https://api.pushshift.io/reddit/submission/search/?subreddit={subreddit}&after={after}&before={before}&selftext={query}&selftext:not={exclude}"
What is the equivalent here? selftext_not
and selftextnot
don't seem to work.
Turns out the function psaw_api.search_submissions()
simply takes a kwargs and builds a get url with the key value pairs to hit the pushshift endpoint. With that being the case all you'd need to do is pass in selftext:not
into the kwargs as a key and the query as it's value. Of course, python doesn't allow a colon and the not keyword when assigning a key, so instead you can just pass in a dictionary with the spread operator as the kwargs.
So instead of this:
psaw_api.search_submissions(subreddit="politics", selftext="[removed]|[deleted]")
you can do this:
psaw_api.search_submissions(**{"subreddit": "politics", "selftext:not": "[removed]|[deleted]"})
With this example I'm able to search for text that is not removed or deleted. An extra interesting behavior that might be useful to note is that if you pass in a praw instance into your psaw api, psaw will request the submission ids from pushshift, but then lookup those submissions live using praw, therefore there can be differences between the current submission and what was archived by pushshift.