1
0
mirror of https://github.com/searx/searx synced 2024-12-28 03:55:14 +01:00

Merge pull request #1842 from piplongrun/engine-etools

Add new eTools.ch engine
This commit is contained in:
Markus Heiser 2020-02-23 11:52:29 +00:00 committed by GitHub
commit 8c26097757
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 59 additions and 0 deletions

54
searx/engines/etools.py Normal file
View File

@ -0,0 +1,54 @@
"""
eTools (Web)
@website https://www.etools.ch
@provide-api no
@using-api no
@results HTML
@stable no (HTML can change)
@parse url, title, content
"""
from lxml import html
from searx.engines.xpath import extract_text
from searx.url_utils import quote
from searx.utils import eval_xpath
categories = ['general']
paging = False
language_support = False
safesearch = True
base_url = 'https://www.etools.ch'
search_path = '/searchAdvancedSubmit.do'\
'?query={search_term}'\
'&pageResults=20'\
'&safeSearch={safesearch}'
def request(query, params):
if params['safesearch']:
safesearch = 'true'
else:
safesearch = 'false'
params['url'] = base_url + search_path.format(search_term=quote(query), safesearch=safesearch)
return params
def response(resp):
results = []
dom = html.fromstring(resp.text)
for result in eval_xpath(dom, '//table[@class="result"]//td[@class="record"]'):
url = eval_xpath(result, './a/@href')[0]
title = extract_text(eval_xpath(result, './a//text()'))
content = extract_text(eval_xpath(result, './/div[@class="text"]//text()'))
results.append({'url': url,
'title': title,
'content': content})
return results

View File

@ -203,6 +203,11 @@ engines:
timeout: 3.0
disabled : True
- name : etools
engine : etools
shortcut : eto
disabled : True
- name : etymonline
engine : xpath
paging : True