Using PRAW 4 to search posts on reddit, works for specific subreddits but doesn't work for 'all'

1.2k views Asked by At

I'm using PRAW 4 in a script app to search through reddit. When I search within specific subreddit, I get some results, but when I try to search in the 'all' subreddit, I get zero results. Code:

all = reddit.subreddit("all")
for i in all.search("yellow car", limit=5):
    print i.title
cars = reddit.subreddit("cars")
for i in cars.search("yellow car", limit=5):
    print i.title

Console log:

DEBUG:prawcore:Fetching: GET https://oauth.reddit.com/r/all/search/
DEBUG:prawcore:Headers: {'Authorization': 'bearer tokenremoved'}
DEBUG:prawcore:Data: None
DEBUG:prawcore:Params: {'sort': 'relevance', 'raw_json': 1, 'syntax': 'cloudsearch', 'q': 'yellow car', 'limit': 5, 't': 'all', 'restrict_sr': True}
DEBUG:prawcore:Response: 200 (107 bytes)
DEBUG:prawcore:Fetching: GET https://oauth.reddit.com/r/cars/search/
DEBUG:prawcore:Headers: {'Authorization': 'bearer tokenremoved'}
DEBUG:prawcore:Data: None
DEBUG:prawcore:Params: {'sort': 'relevance', 'raw_json': 1, 'syntax': 'cloudsearch', 'q': 'yellow car', 'limit': 5, 't': 'all', 'restrict_sr': True}
DEBUG:prawcore:Response: 200 (3552 bytes)
Why do most American cars have yellow in their headlights, while foreign equivalents often don't?
The M5 is a great family car!
You can have 2 cars, your daily driver and something else.  You already have your daily driver and 100k (USD) to spend.  What do you buy?
What's in your dream 5-car garage?
I bought my first car today r/cars!

I dug out json response for the 'all' search request:

{u'kind': u'Listing', u'data': {u'facets': {}, u'modhash': None, u'children': [], u'after': None, u'before': None}}

No errors, just empty results.

Anyone has any idea why searching 'all' wouldn't return results or what would be the next step to debug this thing? Thanks!

1

There are 1 answers

0
bboe On BEST ANSWER

This search issue is a bug in PRAW 4.0.0. You should be able to search, exactly as you are doing by installing the latest development version of PRAW4. You can install that version via:

pip install --upgrade https://github.com/praw-dev/praw/archive/master.zip