Keyword exact match search for Reddit using praw subreddit.search

57 Views Asked by At

I am new to using praw library for reddit, and I'm using subreddit.search

my code goes something like this

subreddit = reddit.subreddit("REDDITNAME")
for submission in subreddit.search("(sample keyword)", limit=None, time_filter="all"):
....

I want to search for results that has the exact phrase "sample keyword", not just "sample" and "keyword" in the text. How can I do this? Thanks!

1

There are 1 best solutions below

0
TheHungryCub On

To search for the exact phrase "sample keyword" using PRAW, you can enclose the phrase in double quotes within the search query:

subreddit = reddit.subreddit("REDDITNAME")
for submission in subreddit.search("\"sample keyword\"", limit=None, time_filter="all"):