@@ -5,10 +5,10 @@
55# pylint: disable=missing-function-docstring, invalid-name
66
77import re
8−from json import loads, JSONDecodeError
8+from json import loads
99from urllib.parse import urlencode
10+# from searx import logger
1011from searx.network import get
11−from searx.exceptions import SearxEngineResponseException
1212
1313# about
1414about = {
@@ -22,9 +22,6 @@ about = {
2222
2323# engine dependent config
2424categories = ['general']
25−collections = 'main'
26−search_type = ''
27−fast = 0
2825# gigablast's pagination is totally damaged, don't use it
2926paging = False
3027safesearch = True
@@ -37,8 +34,6 @@ base_url = 'https://gigablast.com'
3734extra_param = ''
3835extra_param_path='/search?c=main&qlangcountry=en-us&q=south&s=10'
3936
40−_wait_for_results_msg = 'Loading results takes too long. Please enable fast option in gigablast engine.'
41−
4237def parse_extra_param(text):
4338
4439 # example:
@@ -59,6 +54,7 @@ def parse_extra_param(text):
5954 if re_var is not None and re_var.search(line):
6055 extra_param += re_var.search(line).group(1)
6156 break
57+ # logger.debug('gigablast extra_param="%s"', extra_param)
6258
6359def init(engine_settings=None): # pylint: disable=unused-argument
6460 parse_extra_param(get(base_url + extra_param_path).text)
@@ -69,17 +65,14 @@ def request(query, params): # pylint: disable=unused-argument
6965
7066 # see API http://www.gigablast.com/api.html#/search
7167 # Take into account, that the API has some quirks ..
72− query_args = {
73− 'c': collections,
74− 'format': 'json',
75− 'q': query,
76− 'dr': 1 ,
77− 'showgoodimages': 0,
78− 'fast': fast,
79− }
80−
81− if search_type != '':
82− query_args['searchtype'] = search_type
68+
69+ query_args = dict(
70+ c = 'main'
71+ , format = 'json'
72+ , q = query
73+ , dr = 1
74+ , showgoodimages = 0
75+ )
8376
8477 if params['language'] and params['language'] != 'all':
8578 query_args['qlangcountry'] = params['language']
@@ -97,13 +90,9 @@ def request(query, params): # pylint: disable=unused-argument
9790def response(resp):
9891 results = []
9992
100− try:
101− response_json = loads(resp.text)
102− except JSONDecodeError as e:
103− if 'Waiting for results' in resp.text:
104− raise SearxEngineResponseException(message=_wait_for_results_msg) # pylint: disable=raise-missing-from
105− raise e
93+ response_json = loads(resp.text)
10694
95+ # logger.debug('gigablast returns %s results', len(response_json['results']))
10796
10897 for result in response_json['results']:
10998 # see "Example JSON Output (&format=json)"