on master help sign in
3 files changed+39−23
since splitsnapshots
unifiedsplit
Dockerfile+3−2 searx/engines/gigablast.py+24−13 searx/settings.yml+12−8
Dockerfile+3−2
@@ -51,13 +51,14 @@ RUN apk upgrade --no-cache \
5151 && apk del build-dependencies \
5252 && rm -rf /root/.cache
5353
54−COPY --chown=searx:searx . .
54+COPY searx ./searx
55+COPY dockerfiles ./dockerfiles
5556
5657ARG TIMESTAMP_SETTINGS=0
5758ARG TIMESTAMP_UWSGI=0
5859ARG VERSION_GITCOMMIT=unknown
5960
60−RUN su searx -c "/usr/bin/python3 -m compileall -q searx"; \
61+RUN /usr/bin/python3 -m compileall -q searx; \
6162 touch -c --date=@${TIMESTAMP_SETTINGS} searx/settings.yml; \
6263 touch -c --date=@${TIMESTAMP_UWSGI} dockerfiles/uwsgi.ini; \
6364 if [ ! -z $VERSION_GITCOMMIT ]; then\
searx/engines/gigablast.py+24−13
@@ -5,10 +5,10 @@
55# pylint: disable=missing-function-docstring, invalid-name
66
77import re
8−from json import loads
8+from json import loads, JSONDecodeError
99from urllib.parse import urlencode
10−# from searx import logger
1110from searx.network import get
11+from searx.exceptions import SearxEngineResponseException
1212
1313# about
1414about = {
@@ -22,6 +22,9 @@ about = {
2222
2323# engine dependent config
2424categories = ['general']
25+collections = 'main'
26+search_type = ''
27+fast = 0
2528# gigablast's pagination is totally damaged, don't use it
2629paging = False
2730safesearch = True
@@ -34,6 +37,8 @@ base_url = 'https://gigablast.com'
3437extra_param = ''
3538extra_param_path='/search?c=main&qlangcountry=en-us&q=south&s=10'
3639
40+_wait_for_results_msg = 'Loading results takes too long. Please enable fast option in gigablast engine.'
41+
3742def parse_extra_param(text):
3843
3944 # example:
@@ -54,7 +59,6 @@ def parse_extra_param(text):
5459 if re_var is not None and re_var.search(line):
5560 extra_param += re_var.search(line).group(1)
5661 break
57− # logger.debug('gigablast extra_param="%s"', extra_param)
5862
5963def init(engine_settings=None): # pylint: disable=unused-argument
6064 parse_extra_param(get(base_url + extra_param_path).text)
@@ -65,14 +69,17 @@ def request(query, params): # pylint: disable=unused-argument
6569
6670 # see API http://www.gigablast.com/api.html#/search
6771 # Take into account, that the API has some quirks ..
68−
69− query_args = dict(
70− c = 'main'
71− , format = 'json'
72− , q = query
73− , dr = 1
74− , showgoodimages = 0
75− )
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
7683
7784 if params['language'] and params['language'] != 'all':
7885 query_args['qlangcountry'] = params['language']
@@ -90,9 +97,13 @@ def request(query, params): # pylint: disable=unused-argument
9097def response(resp):
9198 results = []
9299
93− response_json = loads(resp.text)
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
94106
95− # logger.debug('gigablast returns %s results', len(response_json['results']))
96107
97108 for result in response_json['results']:
98109 # see "Example JSON Output (&format=json)"
searx/settings.yml+12−8
@@ -505,6 +505,13 @@ engines:
505505 engine : gigablast
506506 shortcut : gb
507507 timeout : 3.0
508+ # Collection names to search in, separated by whitespaces.
509+ # By default searx, queries the main collection.
510+ #collections: main
511+ # Search types, not required. possible values: images, news
512+ #search_type: images
513+ # Enable fast to get results quicker.
514+ #fast : 1
508515 disabled: True
509516 additional_tests:
510517 rosebud: *test_rosebud
@@ -690,22 +697,19 @@ engines:
690697
691698 - name : hoogle
692699 engine : xpath
693− paging : True
694700 search_url : https://hoogle.haskell.org/?hoogle={query}&start={pageno}
695701 results_xpath : '//div[@class="result"]'
696− title_xpath : './/div[@class="ans"]//a'
697− url_xpath : './/div[@class="ans"]//a/@href'
698− content_xpath : './/div[@class="from"]'
699− page_size : 20
702+ title_xpath : './div[@class="ans"]'
703+ url_xpath : './div[@class="ans"]//a/@href'
704+ content_xpath : './div[contains(@class, "doc")]'
700705 categories : it
701706 shortcut : ho
702707 about:
703− website: https://www.haskell.org/
708+ website: https://hoogle.haskell.org/
704709 wikidata_id: Q34010
705− official_api_documentation: https://hackage.haskell.org/api
706710 use_official_api: false
707711 require_api_key: false
708− results: JSON
712+ results: HTML
709713
710714 - name : imdb
711715 engine : imdb