.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.engines.ahmia Namespace Reference

Functions

 request (query, params)
 
 response (resp)
 

Variables

dict about
 
list categories = ['onions']
 
bool paging = True
 
int page_size = 10
 
str search_url = 'http://juhanurmihxlp77nkq76byazcldy2hlmovfu2epvl5ankdibsot4csyd.onion/search/?{query}'
 
bool time_range_support = True
 
dict time_range_dict = {'day': 1, 'week': 7, 'month': 30}
 
str results_xpath = '//li[@class="result"]'
 
str url_xpath = './h4/a/@href'
 
str title_xpath = './h4/a[1]'
 
str content_xpath = './/p[1]'
 
str correction_xpath = '//*[@id="didYouMean"]//a'
 
str number_of_results_xpath = '//*[@id="totalResults"]'
 

Detailed Description

 Ahmia (Onions)

Function Documentation

◆ request()

searx.engines.ahmia.request ( query,
params )

Definition at line 39 of file ahmia.py.

39def request(query, params):
40 params['url'] = search_url.format(query=urlencode({'q': query}))
41
42 if params['time_range'] in time_range_dict:
43 params['url'] += '&' + urlencode({'d': time_range_dict[params['time_range']]})
44
45 return params
46
47

◆ response()

searx.engines.ahmia.response ( resp)

Definition at line 48 of file ahmia.py.

48def response(resp):
49 results = []
50 dom = fromstring(resp.text)
51
52 # trim results so there's not way too many at once
53 first_result_index = page_size * (resp.search_params.get('pageno', 1) - 1)
54 all_results = eval_xpath_list(dom, results_xpath)
55 trimmed_results = all_results[first_result_index : first_result_index + page_size]
56
57 # get results
58 for result in trimmed_results:
59 # remove ahmia url and extract the actual url for the result
60 raw_url = extract_url(eval_xpath_list(result, url_xpath, min_len=1), search_url)
61 cleaned_url = parse_qs(urlparse(raw_url).query).get('redirect_url', [''])[0]
62
63 title = extract_text(eval_xpath(result, title_xpath))
64 content = extract_text(eval_xpath(result, content_xpath))
65
66 results.append({'url': cleaned_url, 'title': title, 'content': content, 'is_onion': True})
67
68 # get spelling corrections
69 for correction in eval_xpath_list(dom, correction_xpath):
70 results.append({'correction': extract_text(correction)})
71
72 # get number of results
73 number_of_results = eval_xpath(dom, number_of_results_xpath)
74 if number_of_results:
75 try:
76 results.append({'number_of_results': int(extract_text(number_of_results))})
77 except: # pylint: disable=bare-except
78 pass
79
80 return results

Variable Documentation

◆ about

dict searx.engines.ahmia.about
Initial value:
1= {
2 "website": 'http://juhanurmihxlp77nkq76byazcldy2hlmovfu2epvl5ankdibsot4csyd.onion',
3 "wikidata_id": 'Q18693938',
4 "official_api_documentation": None,
5 "use_official_api": False,
6 "require_api_key": False,
7 "results": 'HTML',
8}

Definition at line 11 of file ahmia.py.

◆ categories

list searx.engines.ahmia.categories = ['onions']

Definition at line 21 of file ahmia.py.

◆ content_xpath

str searx.engines.ahmia.content_xpath = './/p[1]'

Definition at line 34 of file ahmia.py.

◆ correction_xpath

str searx.engines.ahmia.correction_xpath = '//*[@id="didYouMean"]//a'

Definition at line 35 of file ahmia.py.

◆ number_of_results_xpath

str searx.engines.ahmia.number_of_results_xpath = '//*[@id="totalResults"]'

Definition at line 36 of file ahmia.py.

◆ page_size

int searx.engines.ahmia.page_size = 10

Definition at line 23 of file ahmia.py.

◆ paging

bool searx.engines.ahmia.paging = True

Definition at line 22 of file ahmia.py.

◆ results_xpath

str searx.engines.ahmia.results_xpath = '//li[@class="result"]'

Definition at line 31 of file ahmia.py.

◆ search_url

str searx.engines.ahmia.search_url = 'http://juhanurmihxlp77nkq76byazcldy2hlmovfu2epvl5ankdibsot4csyd.onion/search/?{query}'

Definition at line 26 of file ahmia.py.

◆ time_range_dict

dict searx.engines.ahmia.time_range_dict = {'day': 1, 'week': 7, 'month': 30}

Definition at line 28 of file ahmia.py.

◆ time_range_support

bool searx.engines.ahmia.time_range_support = True

Definition at line 27 of file ahmia.py.

◆ title_xpath

str searx.engines.ahmia.title_xpath = './h4/a[1]'

Definition at line 33 of file ahmia.py.

◆ url_xpath

str searx.engines.ahmia.url_xpath = './h4/a/@href'

Definition at line 32 of file ahmia.py.