on master help sign in
Merge branch 'master' of https://github.com/asciimoo/searx into add-docs
commit51b9295b84079776e3ea08971ccb3ac159e37477 authorMarkus Heiser <markus.heiser@darmarit.de> dateFri 3 Jan 2020, 14:30 (7 years ago) parentf602cb817b6faa
7 files changed+52−30
docs/admin/installation.rst+15−7 searx/engines/bing.py+2−3 searx/engines/flickr_noapi.py+17−9 searx/engines/ina.py+6−3 searx/engines/microsoft_academic.py+2 searx/engines/scanr_structures.py+1−1 searx/settings.yml+9−7
docs/admin/installation.rst+15−7
@@ -114,6 +114,9 @@ content:
114114 # Module to import
115115 module = searx.webapp
116116
117+ # Support running the module from a webserver subdirectory.
118+ route-run = fixpathinfo:
119+
117120 # Virtualenv and python path
118121 virtualenv = /usr/local/searx/searx-ve/
119122 pythonpath = /usr/local/searx/
@@ -151,7 +154,10 @@ content:
151154 server {
152155 listen 80;
153156 server_name searx.example.com;
154− root /usr/local/searx;
157+ root /usr/local/searx/searx;
158+
159+ location /static {
160+ }
155161
156162 location / {
157163 include uwsgi_params;
@@ -180,14 +186,13 @@ Add this configuration in the server config file
180186
181187.. code:: nginx
182188
183− location = /searx { rewrite ^ /searx/; }
184− location /searx {
185− try_files $uri @searx;
189+ location /searx/static {
190+ alias /usr/local/searx/searx/static;
186191 }
187− location @searx {
192+
193+ location /searx {
188194 uwsgi_param SCRIPT_NAME /searx;
189195 include uwsgi_params;
190− uwsgi_modifier1 30;
191196 uwsgi_pass unix:/run/uwsgi/app/searx/socket;
192197 }
193198
@@ -197,6 +202,10 @@ in case of single-user or low-traffic instances.)
197202
198203.. code:: nginx
199204
205+ location /searx/static {
206+ alias /usr/local/searx/searx/static;
207+ }
208+
200209 location /searx {
201210 proxy_pass http://127.0.0.1:8888;
202211 proxy_set_header Host $host;
@@ -338,4 +347,3 @@ References
338347
339348* How to: `Setup searx in a couple of hours with a free SSL certificate
340349 <https://www.reddit.com/r/privacytoolsIO/comments/366kvn/how_to_setup_your_own_privacy_respecting_search/>`__
341−
searx/engines/bing.py+2−3
@@ -89,8 +89,7 @@ def response(resp):
8989 'content': content})
9090
9191 try:
92− result_len_container = "".join(eval_xpath(dom, '//span[@class="sb_count"]/text()'))
93− result_len_container = utils.to_string(result_len_container)
92+ result_len_container = "".join(eval_xpath(dom, '//span[@class="sb_count"]//text()'))
9493 if "-" in result_len_container:
9594 # Remove the part "from-to" for paginated request ...
9695 result_len_container = result_len_container[result_len_container.find("-") * 2 + 2:]
@@ -102,7 +101,7 @@ def response(resp):
102101 logger.debug('result error :\n%s', e)
103102 pass
104103
105− if _get_offset_from_pageno(resp.search_params.get("pageno", 0)) > result_len:
104+ if result_len and _get_offset_from_pageno(resp.search_params.get("pageno", 0)) > result_len:
106105 return []
107106
108107 results.append({'number_of_results': result_len})
searx/engines/flickr_noapi.py+17−9
@@ -109,14 +109,22 @@ def response(resp):
109109 else:
110110 url = build_flickr_url(photo['ownerNsid'], photo['id'])
111111
112− results.append({'url': url,
113− 'title': title,
114− 'img_src': img_src,
115− 'thumbnail_src': thumbnail_src,
116− 'content': content,
117− 'author': author,
118− 'source': source,
119− 'img_format': img_format,
120− 'template': 'images.html'})
112+ result = {
113+ 'url': url,
114+ 'img_src': img_src,
115+ 'thumbnail_src': thumbnail_src,
116+ 'source': source,
117+ 'img_format': img_format,
118+ 'template': 'images.html'
119+ }
120+ try:
121+ result['author'] = author.encode('utf-8')
122+ result['title'] = title.encode('utf-8')
123+ result['content'] = content.encode('utf-8')
124+ except:
125+ result['author'] = ''
126+ result['title'] = ''
127+ result['content'] = ''
128+ results.append(result)
121129
122130 return results
searx/engines/ina.py+6−3
@@ -32,7 +32,7 @@ base_url = 'https://www.ina.fr'
3232search_url = base_url + '/layout/set/ajax/recherche/result?autopromote=&hf={ps}&b={start}&type=Video&r=&{query}'
3333
3434# specific xpath variables
35−results_xpath = '//div[contains(@class,"search-results--list")]/div[@class="media"]'
35+results_xpath = '//div[contains(@class,"search-results--list")]//div[@class="media-body"]'
3636url_xpath = './/a/@href'
3737title_xpath = './/h3[@class="h3--title media-heading"]'
3838thumbnail_xpath = './/img/@src'
@@ -65,8 +65,11 @@ def response(resp):
6565 videoid = result.xpath(url_xpath)[0]
6666 url = base_url + videoid
6767 title = p.unescape(extract_text(result.xpath(title_xpath)))
68− thumbnail = extract_text(result.xpath(thumbnail_xpath)[0])
69− if thumbnail[0] == '/':
68+ try:
69+ thumbnail = extract_text(result.xpath(thumbnail_xpath)[0])
70+ except:
71+ thumbnail = ''
72+ if thumbnail and thumbnail[0] == '/':
7073 thumbnail = base_url + thumbnail
7174 d = extract_text(result.xpath(publishedDate_xpath)[0])
7275 d = d.split('/')
searx/engines/microsoft_academic.py+2
@@ -45,6 +45,8 @@ def request(query, params):
4545def response(resp):
4646 results = []
4747 response_data = loads(resp.text)
48+ if not response_data:
49+ return results
4850
4951 for result in response_data['results']:
5052 url = _get_url(result)
searx/engines/scanr_structures.py+1−1
@@ -29,7 +29,7 @@ def request(query, params):
2929 params['url'] = search_url
3030 params['method'] = 'POST'
3131 params['headers']['Content-type'] = "application/json"
32− params['data'] = dumps({"query": query,
32+ params['data'] = dumps({"query": query.decode('utf-8'),
3333 "searchField": "ALL",
3434 "sortDirection": "ASC",
3535 "sortOrder": "RELEVANCY",
searx/settings.yml+9−7
@@ -79,9 +79,10 @@ engines:
7979 categories : science
8080 timeout : 4.0
8181
82− - name : base
83− engine : base
84− shortcut : bs
82+# tmp suspended: dh key too small
83+# - name : base
84+# engine : base
85+# shortcut : bs
8586
8687 - name : wikipedia
8788 engine : wikipedia
@@ -552,10 +553,11 @@ engines:
552553 timeout : 10.0
553554 disabled : True
554555
555− - name : scanr structures
556− shortcut: scs
557− engine : scanr_structures
558− disabled : True
556+# tmp suspended: bad certificate
557+# - name : scanr structures
558+# shortcut: scs
559+# engine : scanr_structures
560+# disabled : True
559561
560562 - name : soundcloud
561563 engine : soundcloud