on master help sign in
Dockerfile+3−2
since splitsnapshots
unifiedsplit
@@ -51,13 +51,14 @@ RUN apk upgrade --no-cache \
51 && apk del build-dependencies \
51 && apk del build-dependencies \
52 && rm -rf /root/.cache
52 && rm -rf /root/.cache
53
53
54−COPY --chown=searx:searx . .
54+COPY searx ./searx
55+COPY dockerfiles ./dockerfiles
55
56
56ARG TIMESTAMP_SETTINGS=0
57ARG TIMESTAMP_SETTINGS=0
57ARG TIMESTAMP_UWSGI=0
58ARG TIMESTAMP_UWSGI=0
58ARG VERSION_GITCOMMIT=unknown
59ARG VERSION_GITCOMMIT=unknown
59
60
60−RUN su searx -c "/usr/bin/python3 -m compileall -q searx"; \
61+RUN /usr/bin/python3 -m compileall -q searx; \
61 touch -c --date=@${TIMESTAMP_SETTINGS} searx/settings.yml; \
62 touch -c --date=@${TIMESTAMP_SETTINGS} searx/settings.yml; \
62 touch -c --date=@${TIMESTAMP_UWSGI} dockerfiles/uwsgi.ini; \
63 touch -c --date=@${TIMESTAMP_UWSGI} dockerfiles/uwsgi.ini; \
63 if [ ! -z $VERSION_GITCOMMIT ]; then\
64 if [ ! -z $VERSION_GITCOMMIT ]; then\
searx/engines/gigablast.py+24−13
@@ -5,10 +5,10 @@
5# pylint: disable=missing-function-docstring, invalid-name
5# pylint: disable=missing-function-docstring, invalid-name
6
6
7import re
7import re
8−from json import loads
8+from json import loads, JSONDecodeError
9from urllib.parse import urlencode
9from urllib.parse import urlencode
10−# from searx import logger
11from searx.network import get
10from searx.network import get
11+from searx.exceptions import SearxEngineResponseException
12
12
13# about
13# about
14about = {
14about = {
@@ -22,6 +22,9 @@ about = {
22
22
23# engine dependent config
23# engine dependent config
24categories = ['general']
24categories = ['general']
25+collections = 'main'
26+search_type = ''
27+fast = 0
25# gigablast's pagination is totally damaged, don't use it
28# gigablast's pagination is totally damaged, don't use it
26paging = False
29paging = False
27safesearch = True
30safesearch = True
@@ -34,6 +37,8 @@ base_url = 'https://gigablast.com'
34extra_param = ''
37extra_param = ''
35extra_param_path='/search?c=main&qlangcountry=en-us&q=south&s=10'
38extra_param_path='/search?c=main&qlangcountry=en-us&q=south&s=10'
36
39
40+_wait_for_results_msg = 'Loading results takes too long. Please enable fast option in gigablast engine.'
41+
37def parse_extra_param(text):
42def parse_extra_param(text):
38
43
39 # example:
44 # example:
@@ -54,7 +59,6 @@ def parse_extra_param(text):
54 if re_var is not None and re_var.search(line):
59 if re_var is not None and re_var.search(line):
55 extra_param += re_var.search(line).group(1)
60 extra_param += re_var.search(line).group(1)
56 break
61 break
57− # logger.debug('gigablast extra_param="%s"', extra_param)
58
62
59def init(engine_settings=None): # pylint: disable=unused-argument
63def init(engine_settings=None): # pylint: disable=unused-argument
60 parse_extra_param(get(base_url + extra_param_path).text)
64 parse_extra_param(get(base_url + extra_param_path).text)
@@ -65,14 +69,17 @@ def request(query, params): # pylint: disable=unused-argument
65
69
66 # see API http://www.gigablast.com/api.html#/search
70 # see API http://www.gigablast.com/api.html#/search
67 # Take into account, that the API has some quirks ..
71 # Take into account, that the API has some quirks ..
68−
69− query_args = dict(
72+ query_args = {
70− c = 'main'
73+ 'c': collections,
71− , format = 'json'
74+ 'format': 'json',
72− , q = query
75+ 'q': query,
73− , dr = 1
76+ 'dr': 1 ,
74− , showgoodimages = 0
77+ 'showgoodimages': 0,
75− )
78+ 'fast': fast,
79+ }
80+
81+ if search_type != '':
82+ query_args['searchtype'] = search_type
76
83
77 if params['language'] and params['language'] != 'all':
84 if params['language'] and params['language'] != 'all':
78 query_args['qlangcountry'] = params['language']
85 query_args['qlangcountry'] = params['language']
@@ -90,9 +97,13 @@ def request(query, params): # pylint: disable=unused-argument
90def response(resp):
97def response(resp):
91 results = []
98 results = []
92
99
100+ try:
93− response_json = loads(resp.text)
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
94
106
95− # logger.debug('gigablast returns %s results', len(response_json['results']))
96
107
97 for result in response_json['results']:
108 for result in response_json['results']:
98 # see "Example JSON Output (&format=json)"
109 # see "Example JSON Output (&format=json)"
searx/settings.yml+12−8
@@ -505,6 +505,13 @@ engines:
505 engine : gigablast
505 engine : gigablast
506 shortcut : gb
506 shortcut : gb
507 timeout : 3.0
507 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
508 disabled: True
515 disabled: True
509 additional_tests:
516 additional_tests:
510 rosebud: *test_rosebud
517 rosebud: *test_rosebud
@@ -690,22 +697,19 @@ engines:
690
697
691 - name : hoogle
698 - name : hoogle
692 engine : xpath
699 engine : xpath
693− paging : True
694 search_url : https://hoogle.haskell.org/?hoogle={query}&start={pageno}
700 search_url : https://hoogle.haskell.org/?hoogle={query}&start={pageno}
695 results_xpath : '//div[@class="result"]'
701 results_xpath : '//div[@class="result"]'
696− title_xpath : './/div[@class="ans"]//a'
702+ title_xpath : './div[@class="ans"]'
697− url_xpath : './/div[@class="ans"]//a/@href'
703+ url_xpath : './div[@class="ans"]//a/@href'
698− content_xpath : './/div[@class="from"]'
704+ content_xpath : './div[contains(@class, "doc")]'
699− page_size : 20
700 categories : it
705 categories : it
701 shortcut : ho
706 shortcut : ho
702 about:
707 about:
703− website: https://www.haskell.org/
708+ website: https://hoogle.haskell.org/
704 wikidata_id: Q34010
709 wikidata_id: Q34010
705− official_api_documentation: https://hackage.haskell.org/api
706 use_official_api: false
710 use_official_api: false
707 require_api_key: false
711 require_api_key: false
708− results: JSON
712+ results: HTML
709
713
710 - name : imdb
714 - name : imdb
711 engine : imdb
715 engine : imdb