mirror of
https://github.com/searxng/searxng
synced 2024-11-07 03:20:28 +00:00
Merge pull request #474 from pointhi/gigablast-improvements
[enh] improve gigablast engine
This commit is contained in:
commit
91c850ca6e
@ -19,11 +19,21 @@ from time import time
|
|||||||
# engine dependent config
|
# engine dependent config
|
||||||
categories = ['general']
|
categories = ['general']
|
||||||
paging = True
|
paging = True
|
||||||
number_of_results = 5
|
number_of_results = 10
|
||||||
|
language_support = True
|
||||||
|
safesearch = True
|
||||||
|
|
||||||
# search-url, invalid HTTPS certificate
|
# search-url
|
||||||
base_url = 'https://gigablast.com/'
|
base_url = 'https://gigablast.com/'
|
||||||
search_string = 'search?{query}&n={number_of_results}&s={offset}&format=xml&qh=0&rxiyd={rxiyd}&rand={rand}'
|
search_string = 'search?{query}'\
|
||||||
|
'&n={number_of_results}'\
|
||||||
|
'&s={offset}'\
|
||||||
|
'&format=xml'\
|
||||||
|
'&qh=0'\
|
||||||
|
'&rxiyd={rxiyd}'\
|
||||||
|
'&rand={rand}'\
|
||||||
|
'&qlang={lang}'\
|
||||||
|
'&ff={safesearch}'
|
||||||
|
|
||||||
# specific xpath variables
|
# specific xpath variables
|
||||||
results_xpath = '//response//result'
|
results_xpath = '//response//result'
|
||||||
@ -36,12 +46,23 @@ content_xpath = './/sum'
|
|||||||
def request(query, params):
|
def request(query, params):
|
||||||
offset = (params['pageno'] - 1) * number_of_results
|
offset = (params['pageno'] - 1) * number_of_results
|
||||||
|
|
||||||
search_path = search_string.format(
|
if params['language'] == 'all':
|
||||||
query=urlencode({'q': query}),
|
language = 'xx'
|
||||||
offset=offset,
|
else:
|
||||||
number_of_results=number_of_results,
|
language = params['language'][0:2]
|
||||||
rxiyd=randint(10000, 10000000),
|
|
||||||
rand=int(time()))
|
if params['safesearch'] >= 1:
|
||||||
|
safesearch = 1
|
||||||
|
else:
|
||||||
|
safesearch = 0
|
||||||
|
|
||||||
|
search_path = search_string.format(query=urlencode({'q': query}),
|
||||||
|
offset=offset,
|
||||||
|
number_of_results=number_of_results,
|
||||||
|
rxiyd=randint(10000, 10000000),
|
||||||
|
rand=int(time()),
|
||||||
|
lang=language,
|
||||||
|
safesearch=safesearch)
|
||||||
|
|
||||||
params['url'] = base_url + search_path
|
params['url'] = base_url + search_path
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ class TestGigablastEngine(SearxTestCase):
|
|||||||
query = 'test_query'
|
query = 'test_query'
|
||||||
dicto = defaultdict(dict)
|
dicto = defaultdict(dict)
|
||||||
dicto['pageno'] = 0
|
dicto['pageno'] = 0
|
||||||
|
dicto['language'] = 'all'
|
||||||
params = gigablast.request(query, dicto)
|
params = gigablast.request(query, dicto)
|
||||||
self.assertTrue('url' in params)
|
self.assertTrue('url' in params)
|
||||||
self.assertTrue(query in params['url'])
|
self.assertTrue(query in params['url'])
|
||||||
|
Loading…
Reference in New Issue
Block a user