@@ -1,67 +0,0 @@
1−# SPDX-License-Identifier: AGPL-3.0-or-later
2−"""
3− not Evil (Onions)
4−"""
5−
6−from urllib.parse import urlencode
7−from lxml import html
8−from searx.engines.xpath import extract_text
9−
10−# about
11−about = {
12− "website": 'http://hss3uro2hsxfogfq.onion',
13− "wikidata_id": None,
14− "official_api_documentation": 'http://hss3uro2hsxfogfq.onion/api.htm',
15− "use_official_api": False,
16− "require_api_key": False,
17− "results": 'HTML',
18−}
19−
20−# engine dependent config
21−categories = ['onions']
22−paging = True
23−page_size = 20
24−
25−# search-url
26−base_url = 'http://hss3uro2hsxfogfq.onion/'
27−search_url = 'index.php?{query}&hostLimit=20&start={pageno}&numRows={page_size}'
28−
29−# specific xpath variables
30−results_xpath = '//*[@id="content"]/div/p'
31−url_xpath = './span[1]'
32−title_xpath = './a[1]'
33−content_xpath = './text()'
34−
35−
36−# do search-request
37−def request(query, params):
38− offset = (params['pageno'] - 1) * page_size
39−
40− params['url'] = base_url + search_url.format(pageno=offset,
41− query=urlencode({'q': query}),
42− page_size=page_size)
43−
44− return params
45−
46−
47−# get response from search-request
48−def response(resp):
49− results = []
50−
51− # needed because otherwise requests guesses wrong encoding
52− resp.encoding = 'utf8'
53− dom = html.fromstring(resp.text)
54−
55− # parse results
56− for result in dom.xpath(results_xpath):
57− url = extract_text(result.xpath(url_xpath)[0])
58− title = extract_text(result.xpath(title_xpath)[0])
59− content = extract_text(result.xpath(content_xpath))
60−
61− # append result
62− results.append({'url': url,
63− 'title': title,
64− 'content': content,
65− 'is_onion': True})
66−
67− return results