Loading docs/dev/engine_overview.rst +4 −3 Original line number Original line Diff line number Diff line Loading @@ -134,9 +134,9 @@ The function ``def request(query, params):`` always returns the ``params`` variable. Inside searx, the following paramters can be used to specify a search variable. Inside searx, the following paramters can be used to specify a search request: request: ================== =========== ======================================================================== ================== =========== ========================================================================== argument type information argument type information ================== =========== ======================================================================== ================== =========== ========================================================================== url string requested url url string requested url method string HTTP request method method string HTTP request method headers set HTTP header information headers set HTTP header information Loading @@ -145,7 +145,8 @@ cookies set HTTP cookies verify boolean Performing SSL-Validity check verify boolean Performing SSL-Validity check max_redirects int maximum redirects, hard limit max_redirects int maximum redirects, hard limit soft_max_redirects int maximum redirects, soft limit. Record an error but don't stop the engine soft_max_redirects int maximum redirects, soft limit. Record an error but don't stop the engine ================== =========== ======================================================================== raise_for_status bool True by default: raise an exception if the HTTP code of response is >= 300 ================== =========== ========================================================================== example code example code Loading searx/engines/wikipedia.py +3 −1 Original line number Original line Diff line number Diff line Loading @@ -37,13 +37,15 @@ def request(query, params): language=url_lang(params['language'])) language=url_lang(params['language'])) params['headers']['User-Agent'] = searx_useragent() params['headers']['User-Agent'] = searx_useragent() params['raise_for_status'] = False params['soft_max_redirects'] = 2 return params return params # get response from search-request # get response from search-request def response(resp): def response(resp): if not resp.ok: if resp.status_code == 404: return [] return [] results = [] results = [] Loading searx/search.py +4 −2 Original line number Original line Diff line number Diff line Loading @@ -143,6 +143,7 @@ def send_http_request(engine, request_params): response = req(request_params['url'], **request_args) response = req(request_params['url'], **request_args) # check HTTP status # check HTTP status if request_params.get('raise_for_status'): response.raise_for_status() response.raise_for_status() # check soft limit of the redirect count # check soft limit of the redirect count Loading Loading @@ -340,7 +341,8 @@ def default_request_params(): 'url': '', 'url': '', 'cookies': {}, 'cookies': {}, 'verify': True, 'verify': True, 'auth': None 'auth': None, 'raise_for_status': True } } Loading Loading
docs/dev/engine_overview.rst +4 −3 Original line number Original line Diff line number Diff line Loading @@ -134,9 +134,9 @@ The function ``def request(query, params):`` always returns the ``params`` variable. Inside searx, the following paramters can be used to specify a search variable. Inside searx, the following paramters can be used to specify a search request: request: ================== =========== ======================================================================== ================== =========== ========================================================================== argument type information argument type information ================== =========== ======================================================================== ================== =========== ========================================================================== url string requested url url string requested url method string HTTP request method method string HTTP request method headers set HTTP header information headers set HTTP header information Loading @@ -145,7 +145,8 @@ cookies set HTTP cookies verify boolean Performing SSL-Validity check verify boolean Performing SSL-Validity check max_redirects int maximum redirects, hard limit max_redirects int maximum redirects, hard limit soft_max_redirects int maximum redirects, soft limit. Record an error but don't stop the engine soft_max_redirects int maximum redirects, soft limit. Record an error but don't stop the engine ================== =========== ======================================================================== raise_for_status bool True by default: raise an exception if the HTTP code of response is >= 300 ================== =========== ========================================================================== example code example code Loading
searx/engines/wikipedia.py +3 −1 Original line number Original line Diff line number Diff line Loading @@ -37,13 +37,15 @@ def request(query, params): language=url_lang(params['language'])) language=url_lang(params['language'])) params['headers']['User-Agent'] = searx_useragent() params['headers']['User-Agent'] = searx_useragent() params['raise_for_status'] = False params['soft_max_redirects'] = 2 return params return params # get response from search-request # get response from search-request def response(resp): def response(resp): if not resp.ok: if resp.status_code == 404: return [] return [] results = [] results = [] Loading
searx/search.py +4 −2 Original line number Original line Diff line number Diff line Loading @@ -143,6 +143,7 @@ def send_http_request(engine, request_params): response = req(request_params['url'], **request_args) response = req(request_params['url'], **request_args) # check HTTP status # check HTTP status if request_params.get('raise_for_status'): response.raise_for_status() response.raise_for_status() # check soft limit of the redirect count # check soft limit of the redirect count Loading Loading @@ -340,7 +341,8 @@ def default_request_params(): 'url': '', 'url': '', 'cookies': {}, 'cookies': {}, 'verify': True, 'verify': True, 'auth': None 'auth': None, 'raise_for_status': True } } Loading