on master help sign in
Merge pull request #2566 from dalf/remove-yandex

[remove] yandex engine

commit45027765e35ad8704b2ed034c3d7460a2a28b827 authorAlexandre Flament <alex@al-f.net> dateFri 12 Feb 2021, 17:12 (6 years ago) parent50bde935d9db6c
2 files changed−77
searx/engines/yandex.py−72 searx/settings.yml−5
searx/engines/yandex.pydeleted−72
@@ -1,72 +0,0 @@
1−# SPDX-License-Identifier: AGPL-3.0-or-later
2−"""
3− Yahoo (Web)
4−"""
5−
6−from urllib.parse import urlencode, urlparse
7−from lxml import html
8−from searx import logger
9−from searx.exceptions import SearxEngineCaptchaException
10−
11−logger = logger.getChild('yandex engine')
12−
13−# about
14−about = {
15− "website": 'https://yandex.ru/',
16− "wikidata_id": 'Q5281',
17− "official_api_documentation": "?",
18− "use_official_api": False,
19− "require_api_key": False,
20− "results": 'HTML',
21−}
22−
23−# engine dependent config
24−categories = ['general']
25−paging = True
26−
27−default_tld = 'com'
28−language_map = {'ru': 'ru',
29− 'ua': 'ua',
30− 'be': 'by',
31− 'kk': 'kz',
32− 'tr': 'com.tr'}
33−
34−# search-url
35−base_url = 'https://yandex.{tld}/'
36−search_url = 'search/?{query}&p={page}'
37−
38−results_xpath = '//li[@class="serp-item"]'
39−url_xpath = './/h2/a/@href'
40−title_xpath = './/h2/a//text()'
41−content_xpath = './/div[@class="text-container typo typo_text_m typo_line_m organic__text"]//text()'
42−
43−
44−def request(query, params):
45− lang = params['language'].split('-')[0]
46− host = base_url.format(tld=language_map.get(lang) or default_tld)
47− params['url'] = host + search_url.format(page=params['pageno'] - 1,
48− query=urlencode({'text': query}))
49− return params
50−
51−
52−# get response from search-request
53−def response(resp):
54− resp_url = urlparse(resp.url)
55− if resp_url.path.startswith('/showcaptcha'):
56− raise SearxEngineCaptchaException()
57−
58− dom = html.fromstring(resp.text)
59− results = []
60−
61− for result in dom.xpath(results_xpath):
62− try:
63− res = {'url': result.xpath(url_xpath)[0],
64− 'title': ''.join(result.xpath(title_xpath)),
65− 'content': ''.join(result.xpath(content_xpath))}
66− except:
67− logger.exception('yandex parse crash')
68− continue
69−
70− results.append(res)
71−
72− return results
searx/settings.yml−5
@@ -1009,11 +1009,6 @@ engines:
10091009 shortcut : yh
10101010 disabled : True
10111011
1012− - name : yandex
1013− engine : yandex
1014− shortcut : yn
1015− disabled : True
1016−
10171012 - name : yahoo news
10181013 engine : yahoo_news
10191014 shortcut : yhn