Add nibl search engine
continuous-integration/drone/push Build is passing Details

master
Simon Bruder 2019-08-02 19:57:58 +00:00
parent 1524f77648
commit 2b48ab873e
No known key found for this signature in database
GPG Key ID: 6F03E0000CC5B62F
3 changed files with 46 additions and 0 deletions

View File

@ -22,4 +22,7 @@ WORKDIR /searx
RUN sed -i -e 's/default_on = False/default_on = True/' searx/plugins/oa_doi_rewrite.py \
&& sed -i -e 's/oadoi.org/sci-hub.tw/' searx/preferences.py
COPY engines/* searx/engines/
COPY result_templates/* searx/templates/oscar/result_templates/
ENTRYPOINT ["tini", "--", "gunicorn", "searx.webapp", "--bind", "[::]:8000", "-w", "4"]

28
engines/nibl.py Normal file
View File

@ -0,0 +1,28 @@
from lxml import html
from searx.engines.xpath import extract_text
from searx.url_utils import quote
url = 'https://nibl.co.uk/bots.php'
search_url = url + '?search={query}'
def request(query, params):
params['url'] = search_url.format(query=quote(query))
return params
def response(resp):
results = []
dom = html.fromstring(resp.text.encode('utf-8'))
for result in dom.xpath('//tr[starts-with(@class, "botlistitem")]'):
filename = extract_text(result.xpath('td[@class="filename"]/text()'))
href = url + result.xpath('td[@class="filename"]/a/@href')[0]
filesize = result.xpath('td[@class="filesize"]/text()')[0]
results.append({'url': href,
'title': filename,
'filesize': filesize,
'template': 'file.html'})
return results

View File

@ -0,0 +1,15 @@
{% from 'oscar/macros.html' import result_header, result_sub_header, result_footer, result_footer_rtl, icon %}
{{ result_header(result, favicons) }}
{{ result_sub_header(result) }}
{% if result.filesize %}<br />{{ icon('floppy-disk') }} {{ _('Filesize') }}
<span class="badge">
{{ result.filesize }}
</span>{% endif %}
{% if rtl %}
{{ result_footer_rtl(result) }}
{% else %}
{{ result_footer(result) }}
{% endif %}