@@ -0,0 +1,64 @@
1+# SPDX-License-Identifier: AGPL-3.0-or-later
6+from urllib.parse import urlencode, urlparse
8+from searx.poolrequests import get
9+from searx.exceptions import SearxEngineAccessDeniedException
10+from searx.utils import extract_text, eval_xpath_list, eval_xpath_getindex
14+ "website": "https://www.seznam.cz/",
15+ "wikidata_id": "Q3490485",
16+ "official_api_documentation": "https://api.sklik.cz/",
17+ "use_official_api": False,
18+ "require_api_key": False,
22+base_url = 'https://search.seznam.cz/'
25+def request(query, params):
26+ response_index = get(base_url, headers=params['headers'], raise_for_httperror=True)
27+ dom = html.fromstring(response_index.text)
29+ url_params = {'q': query}
30+ for e in eval_xpath_list(dom, '//input[@type="hidden"]'):
32+ value = e.get('value')
33+ url_params[name] = value
35+ params['url'] = base_url + '?' + urlencode(url_params)
36+ params['cookies'] = response_index.cookies
41+ resp_url = urlparse(resp.url)
42+ if resp_url.path.startswith('/verify'):
43+ raise SearxEngineAccessDeniedException()
47+ dom = html.fromstring(resp.content.decode())
48+ for result_element in eval_xpath_list(dom, '//div[@id="searchpage-root"]//div[@data-dot="results"]/div'):
49+ dot_data = eval_xpath_getindex(result_element, './div/div[@data-dot-data]/@data-dot-data', 0, default=None)
51+ title_element = eval_xpath_getindex(result_element, './/h3/a', 0)
53+ 'url': title_element.get('href'),
54+ 'title': extract_text(title_element),
55+ 'content': extract_text(eval_xpath_getindex(title_element, '../../div[2]', 0)),
57+ elif dot_data == '{"reporter_name":"hint/related/relates"}':
58+ suggestions_element = eval_xpath_getindex(result_element,
59+ './div/div[@data-dot="main-box"]', 0, default=None)
60+ if suggestions_element is not None:
61+ for suggestion in eval_xpath_list(suggestions_element, './/ul/li'):
62+ results.append({'suggestion': extract_text(suggestion)})