|  | @@ -22,6 +22,7 @@ from urllib.parse import urlencode
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  from lxml import html
 |  |  from lxml import html
 | 
											
												
													
														|  |  from searx.utils import extract_text, extract_url, eval_xpath, eval_xpath_list
 |  |  from searx.utils import extract_text, extract_url, eval_xpath, eval_xpath_list
 | 
											
												
													
														|  | 
 |  | +from searx.network import raise_for_httperror
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  search_url = None
 |  |  search_url = None
 | 
											
												
													
														|  |  """
 |  |  """
 | 
											
										
											
												
													
														|  | @@ -61,6 +62,14 @@ lang_all = 'en'
 | 
											
												
													
														|  |  selected.
 |  |  selected.
 | 
											
												
													
														|  |  '''
 |  |  '''
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +no_result_for_http_status = []
 | 
											
												
													
														|  | 
 |  | +'''Return empty result for these HTTP status codes instead of throwing an error.
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +.. code:: yaml
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    no_result_for_http_status: []
 | 
											
												
													
														|  | 
 |  | +'''
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  soft_max_redirects = 0
 |  |  soft_max_redirects = 0
 | 
											
												
													
														|  |  '''Maximum redirects, soft limit. Record an error but don't stop the engine'''
 |  |  '''Maximum redirects, soft limit. Record an error but don't stop the engine'''
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -177,11 +186,18 @@ def request(query, params):
 | 
											
												
													
														|  |      params['url'] = search_url.format(**fargs)
 |  |      params['url'] = search_url.format(**fargs)
 | 
											
												
													
														|  |      params['soft_max_redirects'] = soft_max_redirects
 |  |      params['soft_max_redirects'] = soft_max_redirects
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +    params['raise_for_httperror'] = False
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      return params
 |  |      return params
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -def response(resp):
 |  | 
 | 
											
												
													
														|  | 
 |  | +def response(resp):  # pylint: disable=too-many-branches
 | 
											
												
													
														|  |      '''Scrap *results* from the response (see :ref:`engine results`).'''
 |  |      '''Scrap *results* from the response (see :ref:`engine results`).'''
 | 
											
												
													
														|  | 
 |  | +    if no_result_for_http_status and resp.status_code in no_result_for_http_status:
 | 
											
												
													
														|  | 
 |  | +        return []
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    raise_for_httperror(resp)
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      results = []
 |  |      results = []
 | 
											
												
													
														|  |      dom = html.fromstring(resp.text)
 |  |      dom = html.fromstring(resp.text)
 | 
											
												
													
														|  |      is_onion = 'onions' in categories
 |  |      is_onion = 'onions' in categories
 |